cuốn sách gpt4 ai đã làm

c++ - 使用具有不同编译器版本的 boost 库

In lại Tác giả: Taklimakan 更新时间:2023-11-03 00:15:07 hai mươi bốn 4
mua khóa gpt4 Nike

我用 gcc 版本 4.6.3(在 3.2.0-29-generic#46-Ubuntu 中)编译了 boost 1.54。然后,我使用这个 boost 库开发了我的库。由于我不想每次更改我的库时都重新编译 boost,所以我将已编译的 boost 静态库添加到我的 git 存储库中。

现在,我正在尝试在具有不同版本编译器的不同机器上编译我的库(尝试使用 gcc 4.4 和 gcc 4.7)。我的库编译正常,但在链接时打印以下错误。

`.text._ZN5boost16exception_detail10bad_alloc_D2Ev' referenced in section `.text._ZN5boost16exception_detail10bad_alloc_D1Ev[boost::exception_detail::bad_alloc_::~bad_alloc_()]' of ../external/lib/linux/64/libboost_thread.a(thread.o): defined in discarded section `.text._ZN5boost16exception_detail10bad_alloc_D2Ev[_ZN5boost16exception_detail10bad_alloc_D5Ev]' of ../external/lib/linux/64/libboost_thread.a(thread.o)
`.text._ZN5boost16exception_detail14bad_exception_D2Ev' referenced in section `.text._ZN5boost16exception_detail14bad_exception_D1Ev[boost::exception_detail::bad_exception_::~bad_exception_()]' of ../external/lib/linux/64/libboost_thread.a(thread.o): defined in discarded section `.text._ZN5boost16exception_detail14bad_exception_D2Ev[_ZN5boost16exception_detail14bad_exception_D5Ev]' of ../external/lib/linux/64/libboost_thread.a(thread.o)
`.text._ZN5boost16exception_detail19error_info_injectorINS_21thread_resource_errorEED2Ev' referenced in section `.text._ZN5boost16exception_detail19error_info_injectorINS_21thread_resource_errorEED1Ev[boost::exception_detail::error_info_injector::~error_info_injector()]' of ../external/lib/linux/64/libboost_thread.a(thread.o): defined in discarded section `.text._ZN5boost16exception_detail19error_info_injectorINS_21thread_resource_errorEED2Ev[_ZN5boost16exception_detail19error_info_injectorINS_21thread_resource_errorEED5Ev]' of ../external/lib/linux/64/libboost_thread.a(thread.o)
`.text._ZN5boost16exception_detail19error_info_injectorINS_10lock_errorEED2Ev' referenced in section `.text._ZN5boost16exception_detail19error_info_injectorINS_10lock_errorEED1Ev[boost::exception_detail::error_info_injector::~error_info_injector()]' of ../external/lib/linux/64/libboost_thread.a(thread.o): defined in discarded section `.text._ZN5boost16exception_detail19error_info_injectorINS_10lock_errorEED2Ev[_ZN5boost16exception_detail19error_info_injectorINS_10lock_errorEED5Ev]' of ../external/lib/linux/64/libboost_thread.a(thread.o)
`.text._ZN5boost16exception_detail19error_info_injectorINS_15condition_errorEED2Ev' referenced in section `.text._ZN5boost16exception_detail19error_info_injectorINS_15condition_errorEED1Ev[boost::exception_detail::error_info_injector::~error_info_injector()]' of ../external/lib/linux/64/libboost_thread.a(thread.o): defined in discarded section `.text._ZN5boost16exception_detail19error_info_injectorINS_15condition_errorEED2Ev[_ZN5boost16exception_detail19error_info_injectorINS_15condition_errorEED5Ev]' of ../external/lib/linux/64/libboost_thread.a(thread.o)
coll2: ld trả về 1 trạng thái thoát
make[2]: *** [libHazelcastClientShared_64.so] Error 1
make[1]: *** [CMakeFiles/HazelcastClientShared_64.dir/all] Error 2
make: *** [all] Error 2

PS:我也尝试用另一台具有相同编译器版本的机器进行编译。 (gcc 版本 4.6.3 和 Centos 6.4)

câu trả lời hay nhất

不保证 c++ ABI 在不同编译器版本之间保持一致。这会影响 c++ 名称修改,并可能导致您看到的链接器错误。您必须对所有库使用相同版本的 gcc。

最好的办法是让你的整个系统都使用最新支持的 gcc 版本。如果您的用户确实需要不同的编译器,那么您可以提供不同版本的库 - 每个要支持的编译器一个。

不能保证与使用不同编译器编译的库进行链接。对于静态和共享/动态 C++ 库都是如此。

另请参阅:看看Unusual C++ linker error - 'Defined in discarded section'似乎该问题的公认答案也是使用相同版本的 GCC 编译所有库。

关于c++ - 使用具有不同编译器版本的 boost 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22667114/

hai mươi bốn 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress