简体   繁体   中英

compile application with gcc that is different from library compiled with different gcc version

I want to compile a c++ application with gcc 4.7 and this application is linked with a library which is compiled with gcc 4.4. I just want to know if there is no issue for it?

The answer is: it depends . And this isn't really compiler or system specific. It applies to Visual Studio as well for example.

Basically, there shouldn't be any issue doing such (this is a rather typical scenario).

However, the important question is, what kind of data is passed between the two binary files.

For example, if all strings are passed as char * , then everything is fine. Once you somewhere pass a std::string (or just a pointer or reference to one), then things will break in case the implementation changed between the two files (eg different STL implementation or just changed alignment).

The same is true for other things, even your own custom structs and classes. If the interface is carefully designed, there shouldn't be any issue. If the interface didn't consider such cases, then you might run into issues which could be very hard or next to impossible to debug (random crashes, problems with stack alignment, etc.).

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM