Linking to libsmbclient.so

Steven McClellan steve at mcclellan.org
Thu Mar 11 16:43:52 GMT 2004



On Thursday March 11, 2004 Peter Waechtler wrote:
>> Hello,
>>
>> I am trying to compile a test program and link to the libsmbclient.so 
>> shared library and ld is producing an error:
>>
>> [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 
>> `__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 libsmbclient.so from 
>> C++?
>>

>#ifdef __cplusplus
>extern "C" {
>#endif
>
>int smbc_init(smbc_get_auth_data_fn fn, int debug);
>
>#ifdef __cplusplus
>}
>#endif

Yes, that works great, I should've opened the libsmbclient.h file to see
that the extern "C" was missing for the function prototypes.  I guess that
the next question should be whether the samba developers can add this to the
libsmbclient.h file so that I don't have to maintain a separate one with my
modifications.

-Steve



More information about the samba-technical mailing list