【发布时间】:2020-09-08 09:35:19
【问题描述】:
我很难让我的 sn-p 代码在 centos 7 上运行。
所以,我已经在盒子上安装了这些软件包:
log4cxx.x86_64、log4cxx-devel.x86_64、apr.x86_64、apr-devel.x86_64、 apr-util.x86_64, apr-util-devel.x86_64, glib2.x86_64, glib2-devel.x86_64
在 CMakeList.txt 中,我尝试了一堆组合(成功构建),但在执行二进制文件时得到了相同的结果。
目前,我有这个:
find_package(PkgConfig)
find_library(LOG4CXX_LIBRARY log4cxx)
虽然我很肯定它可以找到图书馆,但我也尝试过:
-llog4cxx -lapr-1 -laprutil-1 -lexpat -lglib-2.0
我使用这两个配置构建,当我运行可执行输出时,我会得到:
undefined symbol: _ZN7log4cxx3xml15DOMConfigurator9configureERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
'nm' 输出是:
$ nm -D /usr/lib64/liblog4cxx.so | grep _ZN7log4cxx3xml15DOMConfigurator9configure
00000000000f9ff0 T _ZN7log4cxx3xml15DOMConfigurator9configureERKSbIwSt11char_traitsIwESaIwEE
00000000000f9e40 T _ZN7log4cxx3xml15DOMConfigurator9configureERKSs
在我的 .cpp 中,我基本上使用了这个:
try {
log4cxx::xml::DOMConfigurator::configure("/root/1.xml");
}
catch (log4cxx::helpers::Exception&) {
fprintf( stderr, "Error on loading Log-config file" );
return -1;
}
ps:同一个项目在 FreeBSD 12 上编译和运行没有问题。
【问题讨论】:
-
对我来说看起来像是 C++ stdlib ABI 问题。您已经标记了 C++17,但 CentOS 7 上的“默认”GCC 是 4.8.5,它早于 C++17。你在用你的构建系统做一些时髦的事情吗?
-
@AsteroidsWithWings,感谢您的反馈。我正在使用 GCC/G++ 10 atm 构建项目
-
(不匹配的符号demangle 到
log4cxx::xml::DOMConfigurator::configure(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)和log4cxx::xml::DOMConfigurator::configure(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)) -
那就是问题所在。您正在安装的软件包是由其他人在不同的工具链上编译的...从源代码构建库。
-
@AsteroidsWithWings,啊啊明白了 :) 让我测试一下并反馈