ld and libsmbclient
steve at mcclellan.org
Tue Mar 9 14:06:39 GMT 2004
On Tuesday, Mar. 9 2004 Peter Waechtler wrote:
>Didn't they tell you to post an error message? ;)
Here is the error message:
[steve at localhost steve]$ gcc testsmbc.cc
/usr/local/samba/lib/libsmbclient.so -o testsmbc
/tmp/cczi0mto.o(.text+0x1f3): In function `main':
: undefined reference to `smbc_init(void (*)(char const*, char const*,
char*, int, char*, int, char*, int), int)'
/tmp/cczi0mto.o(.eh_frame+0x11): undefined reference to
collect2: ld returned 1 exit status
>> I am having some difficulty making ld resolve the functions in the
>> libsmbclient.so when linking. I am using samba 3.0.2a on a fully
>> patched red hat 9 system and the shared library is being built ok.
>> There must be something wrong with the shared library installation.
>> Could somebody please walk me through all of the steps necessary for
>> getting the library installed correctly. The make install only copied
>> the libsmbclient.so.
>> I have added the path to libsmbclient.so in the ld.so.conf file and
>> run ldconfig. I have also verified that the libsmbclient.so is in the
>> ld.so.cache by doing a ldconfig -p. Everything looks good but ld
>> cannot resolve the smbc_init function (or any other function from the
>> library). If I remove the the library path for libsmbclient and then
>> run ldconfig again, ld will produce another error message saying that
>> it can't find the library instead of saying that it can't resolve the
>$ nm /usr/lib/libsmbclient3.so| grep smbc_init
>00020980 T smbc_init
>00020400 T smbc_init_context
>000b2580 b smbc_initialized
>the capital "T" denotes an exported text (code) symbol. If it's a "t" then
it's not exported (defined as static in the code >perhaps).
Yup, the functions are exported as they have the capital "T", just like your
>> I suspect that there is a dependent library or some other similar
>> problem but I can't figure it out. I would run ldd on the executable
>> to check for missing libraries but since I can't link and get an
>> executable file, I'm stuck. I have tried several different versions
>> of samba, all with the same result so I must be missing something.
>So you try to link your program against libsmbclient.so?
>gcc sample.c -L /where/is/smbclient.so -lsmbclient
Yes, except my file extension is .cc instead of .c which I expect changes
everything. I'm not sure what is going on here but I expect that it may be
C++ name mangling? If I change my test code to have a .c extension instead
of a .cc extension then everything works as expected. The problem is that
all of my other code has a .cc extension and so I need to have the samba
code compile and link within the same environment. Is there something easy
that I can do to have the libsmbclient.so library be able to link in a C++
More information about the samba-technical