I have an embedded application that has been written for gcc 3.2.31, and I want to link a library, written by myself, and compiled using g++ 7.2.0.
I have already built and link a test library with almost no code, but now that I am trying something more relevant, I face some issues regarding undefined symbols. Currently, I have the following kind of errors:
undefined reference to
__assert_func
I do not get this error if I compile using g++ 3.2.3.
I want to use g++ 7.2.0 to have access to the new C++14 (maybe C++17) features and some new parts of the standard library (std::chrono::duration
, etc.).
Is there a way to make this work?
I can fix the above issue by defining my own __assert_func
:
extern "C" void __assert(const char *, int, const char *);
extern "C" void __assert_func(
const char *file, int line, const char *, const char *e) {
__assert(file, line, e);
}
...but I was wondering if there is a simpler way? In particular, there may be other name changes and I do not want to have to modify these everytime...
I assume I will not use new features that would require code that is not in the old gcc version (e.g., std::thread
or std::chrono::system_clock
).
Related:
- Linking against an old version of libc to provide greater application coverage, with "solutions" for dynamic libraries, but no better solutions than mine for static libraries (i.e., rewriting the missing symbols).
1 The application and the library are built using the sparc-rtems
gcc toolchains, and some third party tools such as JamaicaVM. I cannot simply change the toolchain used to build the main application because there are many incompatibilities with the new compiler toolchain...