4

boost 版本 1.64
gcc 版本 6.4.1
Linux OpenSuse x64 42.2
Cmake 3.5.2

[链接,无 LTO] 有效:

-std=gnu++11 -O2  -fopenmp -static /opt/lib64/libboost_filesystem.a /opt/lib64/libboost_system.a

[链接,使用 LTO] 不起作用:

-std=gnu++11 -O2  -fopenmp -flto=8 -static /opt/lib64/libboost_filesystem.a /opt/lib64/libboost_system.a

错误:

/opt/lib64/libboost_filesystem.a(operations.o): In function `boost::filesystem::detail::is_empty(boost::filesystem::path const&, boost::system::error_code*)':
operations.cpp:(.text+0x536a): undefined reference to `vtable for boost::detail::sp_counted_impl_p<boost::filesystem::detail::dir_itr_imp>'
/opt/lib64/libboost_filesystem.a(operations.o): In function `(anonymous namespace)::remove_all_aux(boost::filesystem::path const&, boost::filesystem::file_type, boost::system::error_code*)':
operations.cpp:(.text+0x699d): undefined reference to `vtable for boost::detail::sp_counted_impl_p<boost::filesystem::detail::dir_itr_imp>'
operations.cpp:(.text+0x6add): undefined reference to `vtable for boost::detail::sp_counted_impl_p<boost::filesystem::detail::dir_itr_imp>'
collect2: error: ld returned 1 exit status
CMakeFiles/zebr.dir/build.make:137: recipe for target 'zebr' failed

gcc 6.4.1--> 使用和-std=gnu++11标记编译的 boost 库
-->gcc 4.8.5一切正常

4

0 回答 0