Linking Cpp to C

Hello,

I have generated 3 dynamic libraries (libbasic.so, liblia.so and libsos.so), and my application 'crit_pts' successfully compiles and links to these libs using this command.

g++ -m64 -Wl,-O1 -o crit_pts crit_pts.o delaunay.o dt.o flip.o peel.o prep.o print_dt.o search.o trist.o -L/usr/lib64 -lsos -lbasic -llia -lQtGui -L/usr/lib64 -L/usr/X11R6/lib64 -pthread -lpng -lfreetype -lSM -lICE -pthread -pthread -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread

All these libraries have *.c files, since they were written in an ancient age, and uses some declarations that interfere with the modern c++ macro declarations.

The application 'crit_pts' also compiles some *.c files and every thing works fine.

Now, I have a new application 'appl' which only has main.cc file. When I am compiling it, I have to add the compiler flag -fno-operator-names to discard the conflict in macro definitions, and be able to compile cpp. The compilation goes fine, but the linking gives me an error. This is the command that is used to link

g++ -m64 -Wl,-O1 -o appl main.o -L/usr/lib64 -lsos -lbasic -llia -lQtGui -L/usr/lib64 -L/usr/X11R6/lib64 -pthread -lpng -lfreetype -lSM -lICE -pthread -pthread -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread,

and this is the error I get.

main.o: In function `main':
....../appl/main.cc:89: undefined reference to `sos_matrix(int, int, double, int, int)'


The function sos_matrix is being called in the earlier application 'crit_pts' as well, and I cant think of any other difference than switching from *.c to *.cc files.

My question is:

1) could switching from *.c to *.cc create this issue ?
2) what is the work around this ?

Thanks
Harsh
Well, I should have googled before asking. I found the answer here

http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html#faq-32.3

Thanks Anyways
Harsh
Topic archived. No new replies allowed.