The c project is composed by a lot of classes and files. The C++ library is compiled into a ".a" file. When I add the .a file as library to the MakeFile of the C project, it shows a lot of errors like undefined reference to '__gxx_personality_v0'
that may related to the difference between C and C++.
I'm using gcc to compile the C project. But whatever functions I'm calling in the C project are declared as extern C
in the header file of the C++ library.
I really appreciate any help!
You have to use a C++ linker, or use g++
as the link driver instead of gcc
.
The issue is that the basic linker will not link against C++ runtime libraries (the same would be true for a Fortran static library). The C++ driver for your compiler will add these flags for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.