I’ve set(Boost_USE_MULTITHREADED ON) But it still doesn’t use -mt libraries.
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})
I can see serialization process is using only one CPU core (100%) and not using others. and also ldd doesn’t show -mt libraries
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)
Boost Serialization aims at providing thread-safety, but not concurrent serialization via threads.
When installing Boost via a package manager, you will often find library aliases in
/usr/libthat map a more verbose name of the library to a canonical one. In the case of Boost, the “tagged” name includes the multi-threading ability via the-mtsuffix.ldddisplays only the name used by CMake when it invoked the linker, which is the canonical one and not the verbose one with the*-mtsuffix. Because your Boost package installation involved the creation of symlinks of the formyou should not need to worry about the wrong libraries being linked.
In fact, Boost Serialization does not spawn threads by itself, so you should not see an increased number of threads just by using the library. Internally, the serialization library uses a mutex to protect the counter of a shared pointer.