针对不同操作系统编译C ++静态库的建议?

问题描述 投票:2回答:1

假设我使用CentOS 7和GCC 7来编译一个静态库(我们称之为mylib.a),我想在CentOS 6(使用较旧的系统库)上使用它(编译)。

最好的方法是什么?静态链接到libstdc ++等?还有什么?

目前,当我在静态库mylib.a上构建(在CentOS 6上使用gcc 4.x)时,我得到类似的东西:

/opt/boost/boost/date_time/gregorian/gregorian_io.hpp:62: undefined reference to `operator delete(void*, unsigned long)'
mylib.a([myFile].o): In function `std::locale::locale<boost::date_time::date_facet<boost::gregorian::date, char, std::ostreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&, boost::date_time::date_facet<boost::gregorian::date, char, std::ostreambuf_iterator<char, std::char_traits<char> > >*)':
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/locale_classes.tcc:47: undefined reference to `operator delete(void*, unsigned long)'

我怀疑是因为boost_date_time.a不是针对libstdc ++构建的。当它在没有最新开发工具的情况下在CentOS 7上使用gcc 4.x构建时。

思想?

谢谢!

c++ linux gcc boost
1个回答
0
投票

构建在最老的受支持系统上 - 这种方式通常适用于Linux。较新版本的gcc和libstdc ++通常与旧版本兼容。

© www.soinside.com 2019 - 2024. All rights reserved.