Linking to

Steven McClellan steve at
Thu Mar 11 12:46:46 GMT 2004


I am trying to compile a test program and link to the shared
library and ld is producing an error:

[steve at localhost steve]$ gcc
/usr/local/samba/lib/ -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

This test program only makes reference to one function for simplicity in
troubleshooting - smbc_init, and the code has been taken directly from the
libsmbclient example of testsmbc.  The only change is that I have changed
the extension of the source file from .c to .cc.  If I change it back to .c
then it compiles and links just fine, but with the .cc extension it doesn't

I suspect C++ name mangling but I just don't know what is going on.  Since
all of my other source code for the project is .cc and I really can't change
it - I am just trying to add samba capability to it

So, is there any way to be able to link to the from C++?


More information about the samba-technical mailing list