Linking to

Peter Waechtler peter at
Thu Mar 11 13:10:52 GMT 2004

Am Donnerstag, 11. März 2004 13:46 schrieb Steven McClellan:
> Hello,
> 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
> `__gxx_personality_v0'
> 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
> link.
> 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++?

#ifdef __cplusplus
extern "C" {

int smbc_init(smbc_get_auth_data_fn fn, int debug);

#ifdef __cplusplus

More information about the samba-technical mailing list