简体   繁体   English

我可以在gcc 4.2.2和gcc 3.4.2中使用静态库吗

[英]Can I use a static library compiled with gcc 3.4.2 with gcc 4.2.2

I have a static library that is compiled with gcc 3.4.2. 我有一个用gcc 3.4.2编译的静态库。 I am building a shared library that relies on this static lib. 我正在建立一个依赖于此静态库的共享库。 I will be building this shared library (.so) with gcc 4.2.2. 我将使用gcc 4.2.2构建此共享库(.so)。 I was wondering what are the potential pitfalls of using the 3.4.2 static library in a gcc 4.2.2 shared library? 我想知道在gcc 4.2.2共享库中使用3.4.2静态库有哪些潜在的陷阱?

It should be fine. 应该没事的 At the end of the day they are only binaries. 归根结底,它们只是二进制文件。 As long as the 3.4.2 static library is compiled for the same platform as what your shared library will be, you shouldn't have any problems. 只要将3.4.2静态库编译为与共享库使用的平台相同的平台,就不会有任何问题。

If your static library is c++ based then I thought due to ABI changes it probably would not be compatible but according to this other stackoverflow question, gcc is forward compatible starting with gcc 3.4.0. 如果您的静态库是基于c ++的,那么我认为由于ABI的更改,它可能不兼容,但是根据另一个stackoverflow问题,gcc从gcc 3.4.0开始是向前兼容的。 So you could be ok. 这样你就可以了。 I had to rebuild all of my libraries going from gcc 3.0/3.2 to gcc 3.4.6 but I have not done the conversion to post-4.0 yet. 我必须将所有库从gcc 3.0 / 3.2重建到gcc 3.4.6,但尚未完成到4.0后的转换。

GCC ABI Compatibility GCC ABI兼容性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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