- From: Coene Lode <Lode.Coene AT siemens.atea.be>
- To: "'discussion AT sctp.de'" <discussion AT sctp.de>
- Subject: RE: [SCTP-Discussion] undefined reference to sctp_whatever...
- Date: Wed Mar 28 14:27:01 2001
- List-id: SCTP Discussions <discussion.sctp.de>
Well folks,
After some fighting with the compiler and the linker at the IETF in
Minneapolis, we figured out what went wrong.
I am trying to a librabry SCTP.H written in C in a C++ program(using
g++/c++)
That means that the G++ compiler during linking expects the library to be in
the C++ format.
Unfortunaly, the link layout of a C library is different from the layout of
a C++ library. (do a "NM <file>.o | sort | less" on a C and C++ objectfile
and you will notice)
So the C++ linker has to be told that it is linking a C library, not a C++
library.
That can be done via a niffty trick in the SCTP.H file at the top(or at
least before the definition of the structures and functions):
#ifdef __cplusplus
extern "C" {
#endif
At the end of the sctp.h file, you then put:(should close the above { )
#ifdef __cplusplus
}
#endif
This tells the compiler and linker that if the compiler is a C++ compiler,
then the link entries of this library must be interpreted in the C link
format, NOT the C++ link format. If the compiler is NOT a C++
compiler(example C compiler) then this bit of def is ignored(library has
already the correct link format anyway).
The net result is that it will resolve the reference to the functions.
Michael will be including this in one of the next releases of the SCTP lib.
Many thanks to Michael, Piggy and Randy for solving this problem.
yours sincerly,
Lode
Siemens Atea ICN D CS D
Software Development
Atealaan 34
B-2200 Herentals Belgium
Tel +32-14-25-2081 / Fax +32-14-25-3212
E-mail:
lode.coene AT siemens.atea.be
>
-----Original Message-----
>
From: Tuexen Michael
>
[mailto:Michael.Tuexen AT icn.siemens.de]
>
Sent: vrijdag 16 maart 2001 13:06
>
To:
>
'discussion AT sctp.de'
>
Subject: RE: [SCTP-Discussion] undefined reference to sctp_whatever...
>
>
>
Just to make it easier.
>
>
cc -o app app.c -lsctp -lglib -L.
>
>
(the sequence of the arguments might be important)
>
>
To make it even more simpler copy libsctp.a to /usr/local/lib
>
Then you can use
>
>
cc -o app app.c -lsctp -lglib
>
>
Hope that helps
>
>
Best regards
>
Michael
>
>
Michael Tuexen Tel.: +49 89 722 47210
>
Siemens AG Fax: +49 89 722 48212
>
ICN WN CS SE 51 E-mail:
>
Michael.Tuexen AT icn.siemens.de
>
>
> -----Original Message-----
>
> From: Tuexen Michael
>
> [SMTP:Michael.Tuexen AT icn.siemens.de]
>
> Sent: Friday, March 16, 2001 12:20 PM
>
> To:
>
> 'discussion AT sctp.de'
>
> Subject: RE: [SCTP-Discussion] undefined reference to
>
sctp_whatever...
>
>
>
> Dear Lode, Dear all,
>
>
>
> assuming that you have in the working directory the files
>
> app.c
>
> sctp.h
>
> libsctp.a
>
>
>
> You can compile (at least under Max OS X and Linux) the app
>
> using
>
>
>
> cc -o app app.c libsctp.a /usr/local/lib/libglib.a
>
>
>
> the sequence is important. Use gcc if you do not have cc.
>
>
>
> So, we need two libraries:
>
> 1. glib
>
> 2. sctp
>
>
>
> Happy SCTPing
>
> Michael
>
>
>
> Michael Tuexen Tel.: +49 89 722 47210
>
> Siemens AG Fax: +49 89 722 48212
>
> ICN WN CS SE 51 E-mail:
>
> Michael.Tuexen AT icn.siemens.de
>
>
Archive powered by MHonArc 2.6.19+.