I've got a strange problem building an executable coded in C++ that uses a C++ library which itself relies on a C library. I compiled the C modules making up the C library using gcc and all other source modules using g++. Both, the C and C++ library are static libs.
When I include a header file from the C library in C++ source code, I alwas wrap it in extern "C":
extern "C"
{
#include <c-library-header.h>
}
The strange thing now is that get "undefined reference" errors when linking, but these change depending on the order I list the libraries:
- If I list the C library first, all the symbols in that library referenced by C++ modules show as "undefined".
- If I list the C++ library first, all the symbols in that library referenced by C++ modules show as "undefined".
I would have thought to order in which static libs appear on the g++ command-line would be totally irrelevant. Anybody any clues?