Mixing Cpp and C
I am trying to compile a program with three parts main.c, file1.c, and file2.cpp. Main.c and file1.c use MIT Kerberos, krb5, functions but no cpp statements. File2.cpp uses MPIR classes so I need to use the g++ compiler. I don't know if these libraries are important, but I include them for thoroughness.
If I compile and link everything with g++, I get a link error 'undefined reference to krb5_read_message' which is in both main.c and file1.c. I even tried changing the file extensions of main and file1 to cpp - no change.
If I compile main.c and file1.c with gcc, and compile file2.cpp with g++, then link with g++, I get a link error 'undefined reference to MyFunction' which is in file2.cpp.
I don't know if the krb5 build is compiled with gcc or g++, but would it help to force the krb5 build to use the g++ compiler? If so, how do I do that?
Last edited by cmccullo; 07-30-2012 at 10:40 PM.
Reason: typo
|