[Cmake] How to use g++ link C file and c++ libraries?
William A. Hoffman
billlist at nycap . rr . com
Thu, 18 Sep 2003 14:43:00 -0400
If you want to have cmake use the c++ compiler to link,
you can add a dummy c++ file to your target. As long as there
is at least one c++ file in the target, the c++ compiler will
be used for linking.
However, for maximum portability, I think that main should
be compiled by a c++ compiler for a c++ program to initialize
all of its variables correctly.
You could do something like this:
extern "C" cmain(int ac, char** av);
int main(int ac, char** av)
{
return cmain(ac, av);
}
-Bill
At 02:28 PM 9/18/2003, Feng Ma wrote:
>Hi,
>
> I have a C function calling C++ libraries. CMake generate Makefile which use gcc to compile C file and link. Because some libraries are c++, so it will generate a lot of errros.
>
> I manually modified the generated Makefile to use g++ to do linking and it worked. Next time I did make, the Makefile was automatically changed to use gcc again. It will be great if
>we can set it somewhere in CMake to tell CMake that this is a project with
>mixture of c and c++ and should do linking using g++.
>
> Any ideas? Thanks a lot.
>
>-Feng
>
>_________________________________________________________________
>Try MSN Messenger 6.0 with integrated webcam functionality! http://www . msnmessenger-download . com/tracking/reach_webcam
>
>_______________________________________________
>Cmake mailing list
>Cmake at www . cmake . org
>http://www . cmake . org/mailman/listinfo/cmake