Boost日志崩溃的一个简单示例(Linux)

Boost日志崩溃的一个简单示例(Linux),boost,boost-log,Boost,Boost Log,好的,我知道,这个问题听起来和其他问题类似(没有一个问题得到回答),但我不明白为什么会失败。最简单的例子是: #包括 int main(){ BOOST_LOG_Trial(info)@Andreyesmashev的建议帮助我找到了问题所在。显然,这与GCC ABI兼容性和标准库的版本控制有关 很好地解决了这个问题(以及如何解决)。因此对于我前面的示例,我唯一要做的就是在安装时在Linux中设置标准库: conan install .. -s compiler.libcxx=libstdc++

好的,我知道,这个问题听起来和其他问题类似(没有一个问题得到回答),但我不明白为什么会失败。最简单的例子是:

#包括
int main(){

BOOST_LOG_Trial(info)@Andreyesmashev的建议帮助我找到了问题所在。显然,这与GCC ABI兼容性和标准库的版本控制有关

很好地解决了这个问题(以及如何解决)。因此对于我前面的示例,我唯一要做的就是在安装时在Linux中设置标准库:

conan install .. -s compiler.libcxx=libstdc++
显然,柯南假定GCC5使用旧的标准库(Boost的默认版本)


<>我希望这能帮助其他人。

我怀疑,你的提升库可能是用一个不同的C++标准库构建的,而不是编译的代码(即从CLAN到LIbSTDC++ +来自GCC的LBC+ +)。。检查Boost二进制文件和您的二进制文件引用的符号名称。
\uuuCXX11
名称空间中的名称表示libstdc++,
\uuuuu 1
表示libc++。此外,请尝试根据Linux发行版包中提供的Boost进行编译。这实际上是一个很好的提示@Andreyesmashev,如果出现问题,我将更改参数并更新问题我坚持,谢谢!
cmake_minimum_required(VERSION 3.15)
project(concurrency)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
find_package(Boost REQUIRED COMPONENTS log)

add_executable(concurrency main.cpp)
target_link_libraries(concurrency Boost::log)
Reading symbols from concurrency...
(No debugging symbols found in concurrency)
(gdb) run
Starting program: /tmp/build/concurrency
warning: Error disabling address space randomization: Operation not permitted
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.32-4.fc33.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007f1aa97896a2 in __memmove_avx_unaligned_erms () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install libgcc-10.2.1-9.fc33.x86_64 libstdc++-10.2.1-9.fc33.x86_64
(gdb) where
#0  0x00007f1aa97896a2 in __memmove_avx_unaligned_erms () from /lib64/libc.so.6
#1  0x00007f1aa9a92ce0 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long) () from /lib64/libstdc++.so.6
#2  0x000000000040ee81 in boost::log::v2s_mt_posix::aux::basic_ostringstreambuf<char, std::char_traits<char>, std::allocator<char> >::append(char const*, unsigned long) ()
#3  0x000000000040ed15 in boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >::formatted_write(char const*, long) ()
#4  0x000000000040eaee in boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >::operator<<(char const*) ()
#5  0x000000000040e853 in boost::log::v2s_mt_posix::basic_record_ostream<char>::operator<<(char const*) ()
#6  0x000000000040e455 in main ()
conan install .. -s compiler.libcxx=libstdc++