我有set(Boost_USE_MULTITHREADED ON)
,但它仍然不使用-mt
库。
cmake_minimum_required(VERSION 2.6)
PROJECT(app)
set(Boost_USE_MULTITHREADED ON)
FIND_PACKAGE(Boost COMPONENTS filesystem program_options thread serialization REQUIRED)
ADD_EXECUTABLE(app long_list_of_files)
TARGET_LINK_LIBRARIES(app ${Boost_LIBRARIES})
我可以看到序列化过程只使用一个 CPU 内核(100%)而不使用其他内核。而且 ldd 也不显示-mt
库
linux-gate.so.1 => (0xb781f000)
libboost_filesystem.so.1.42.0 => /usr/lib/libboost_filesystem.so.1.42.0 (0xb77e9000)
libboost_program_options.so.1.42.0 => /usr/lib/libboost_program_options.so.1.42.0 (0xb7795000)
libboost_thread.so.1.42.0 => /usr/lib/libboost_thread.so.1.42.0 (0xb7780000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7766000)
libboost_serialization.so.1.42.0 => /usr/lib/libboost_serialization.so.1.42.0 (0xb76f3000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7608000)
libm.so.6 => /lib/libm.so.6 (0xb75e2000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb75c5000)
libc.so.6 => /lib/libc.so.6 (0xb7468000)
libboost_system.so.1.42.0 => /usr/lib/libboost_system.so.1.42.0 (0xb7463000)
librt.so.1 => /lib/librt.so.1 (0xb745a000)
/lib/ld-linux.so.2 (0xb7820000)