Linking static library compiled with g++ 7.2 using gcc 3.2.3

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Linking static library compiled with g++ 7.2 using gcc 3.2.3



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


__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.).


std::chrono::duration



Is there a way to make this work?



I can fix the above issue by defining my own __assert_func:


__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).


std::thread


std::chrono::system_clock



Related:



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...


sparc-rtems





@VTT It's my code that contains such symbol. I have some assert in my code (currently for debugging purpose), and in the recent gcc versions, the assert macro calls __assert_func, while in old version it simply calls __assert and there are no __assert_func does not exist in the old libc.
– Holt
Aug 8 at 8:53



assert


assert


__assert_func


__assert


__assert_func





Actually after rereading your question I've realized that you want to squeeze static libraries build with newer toolchain into old toolchain. I doubt that this is going to work. You may check gcc ABI policies. But even if no linker errors occurs it would probably not going to work correctly.
– VTT
Aug 8 at 9:01






@VTT The current (dirty) fix actually works, it just boils down to finding the right symbols... I was just hoping there would an somehow simple way to tell gcc to build for old libraries, or maybe a list of changes between the two (even if these are years appart... ).
– Holt
Aug 8 at 9:07





@VTT I would be interested to know what kind of problems could occur at runtime once the linker step succeed. That may change my approach on the actual problem.
– Holt
Aug 8 at 9:09





Use older gcc to compile that code (along with library files supplied with older gcc version). There is a clear line in the link @VTT posted: GCC 3.4.0: libstdc++.so.6.0.0 (Incompatible with previous). The only releable way would be to check gcc commits for changes. Or you can try linking both old and newer library with some objcopy renaming tricks.
– Kamil Cuk
Aug 8 at 9:32



GCC 3.4.0: libstdc++.so.6.0.0 (Incompatible with previous)









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.