I had a strange problem creating an executable code written in C ++ that uses the C ++ library, which itself relies on the C library. I compiled the C modules that make up the C library using gcc and all other source modules using g ++ . Both C and C ++ libraries are static libraries.
When I include the header file from the C library in the C ++ source code, I also wrap it in extern "C":
extern "C"
{
#include <c-library-header.h>
}
The strange thing is that when linking, "undefined reference" errors occur, but they change depending on the order in which I list the libraries:
- If I first listed the C library, all the characters in this library referenced by the C ++ modules are displayed as "undefined".
- If I first listed the C ++ library, all the characters in this library referenced by the C ++ modules are displayed as "undefined".
I would think that the order in which static libraries appear on the g ++ command line would be completely irrelevant. Someone tell me?
source
share