Linking C and C++ together

Daniel Kraft d@daniel-kraft.net
Thu Apr 21 16:47:00 GMT 2005


Dear GCC-team,

I want to use both C and C++ in a program (unfortunatly, the C source isn't
compatible with C++), and therefore I must compile the C files with "-x c"
(otherwise I get lots of errors, due to old-style function definitions).
This works just fine, but when I try to link both objects together, C++ doesn't
find the C functions and the other way round! (undefined reference)
May this be because I use an older cygwin-version of GCC (3.3.3)? Is there any
work-around (e. g., allowing C code to be compiled into C++ compatible objects)?
I looked through the manual, but I wasn't able to find a solution...

Many thanks,
Daniel Kraft



More information about the Gcc-help mailing list