compiling c code but libraries are compiled in c++

hi, We have written cunit code for testing some APIs. defination of those APIs are in c++ and .so library is created of them. when I compile my cunit code it gets compiled successfully but while liking it gives undefined reference to symbol. can anyone help me in this matter.

Regards Sumit Shrivastava

Reply to
sumit
Loading thread data ...

| We have written cunit code for testing some APIs. defination of | those APIs are in c++ and .so library is created of them. when I | compile my cunit code it gets compiled successfully but while liking | it gives undefined reference to symbol. can anyone help me in this | matter.

C++ mangles the symbols so it can enforce function argument type matching at linking time. You will need to find out how they are mangled and use those same names in C. Or change the C++ programs to define the functions as special C type.

--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org)  /  Do not send to the address below |
| first name lower case at ipal.net   /  spamtrap-2007-05-29-0654@ipal.net |
|------------------------------------/-------------------------------------|
Reply to
phil-news-nospam

the problem is the name mangling of the C++ compiler:

formatting link

a extern "C" declaration around the include of C headers should resolve the problem:

extern "C" { #include }

regards

Matthias Kaehlcke Linux Application Developer Barcelona

The yellow ships hung in the air just like bricks dont do (The Hitch-Hiker's Guide to the Galaxy)

using free software / Debian GNU/Linux |

formatting link

gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4

Reply to
Matthias Kaehlcke

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.