Mixing C and C++
Hi all
I was wondering if any of you have any experience with compiling C++ mixed with C under Linux (using g++)?
I have some C functions that I've been given and I want to use them in a C++ program. Unfortunately, the compiler can't link to any of the C functions I've used. I've looked on the internet and all it says is that I have to enclose the C decelerations in an extern "C" statement and use the C++ compiler to compile main and link it all together. Unfortunately, the functions are already enclosed in an extern "C" statement, I'm already using the C++ compiler to compile main and link and I'm getting rather sick and tired of having the internet tell me that all is well with my set up.
Anyway, have any of you had this kind of a problem? Do you have any advice?
Thanks.
Edit: Solved. Turned out not to be a linker error at all, but a preprocessor error. The code I was given had a #ifdef command right at the beginning. I figured out that I had to look for it beacuse, when using ld's manual page, it mentioned the (extremely useful) objdump command. I objdump -d the offending .o file and found it empty of all content.
If you've read this, thank you anyway, it helped me to post about it and then I could think a bit more clearly.
I was wondering if any of you have any experience with compiling C++ mixed with C under Linux (using g++)?
I have some C functions that I've been given and I want to use them in a C++ program. Unfortunately, the compiler can't link to any of the C functions I've used. I've looked on the internet and all it says is that I have to enclose the C decelerations in an extern "C" statement and use the C++ compiler to compile main and link it all together. Unfortunately, the functions are already enclosed in an extern "C" statement, I'm already using the C++ compiler to compile main and link and I'm getting rather sick and tired of having the internet tell me that all is well with my set up.
Anyway, have any of you had this kind of a problem? Do you have any advice?
Thanks.
Edit: Solved. Turned out not to be a linker error at all, but a preprocessor error. The code I was given had a #ifdef command right at the beginning. I figured out that I had to look for it beacuse, when using ld's manual page, it mentioned the (extremely useful) objdump command. I objdump -d the offending .o file and found it empty of all content.
If you've read this, thank you anyway, it helped me to post about it and then I could think a bit more clearly.
