I'm on Window (OS) and trying to do the Boost::Asio tutorial. I successfully added Boost but once I try to add a component (system, thread, regex, ...) it fails ... All of this is working on my Ubuntu. But on my Window (OS) it's not working ...
I installed boost to my pc then added it to my project thanks to CMake.
find_package(Boost 1.82.0 REQUIRED)
target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARY_DIRS})
Then I'm doing the Boost::Asio tutorials and I need to add the boost::thread. I alter my CMake to add the required boost components (system, thread and regex)
find_package(Boost 1.82.0 COMPONENTS system thread regex REQUIRED)
target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(${AJC_PROJECT_NAME} ${Boost_LIBRARY_DIRS} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_REGEX_LIBRARY})
Then from now CMake is not working anymore :( Looking through stackoverflow and others ressources I added a few lines to my CMake
set(Boost_USE_STATIC_LIBS ON)
set(Boost_DEBUG ON)
find_package(Boost 1.82.0 COMPONENTS system thread regex REQUIRED)
target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(${AJC_PROJECT_NAME} ${Boost_LIBRARY_DIRS} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_REGEX_LIBRARY})
I even tried
CMAKE -- set(Boost_NO_BOOST_CMAKE ON)
ENV -- BOOST_INCLUDEDIR = C:\boost_1_82_0\boost
ENV -- BOOST_LIBRARYDIR = C:\boost_1_82_0\stage\lib (and C:\boost_1_82_0\libs)
ENV -- BOOST_ROOT = C:\boost_1_82_0
but nothing works. I got the following errors (I bolded the stacktrace)
-- [ C:/msys64/mingw64/share/cmake/Modules/FindBoost.cmake:2256 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-mgw13-mt-1_82;libboost_system-mgw13-mt;libboost_system-mgw13-mt;libboost_system-mt-1_82;libboost_system-mt;libboost_system-mt;libboost_system-mt;libboost_system;libboost_system-mgw13-mt-s-1_82;libboost_system-mgw13-mt-s;libboost_system-mgw13-mt-s;libboost_system-mt-s-1_82;libboost_system-mt-s;libboost_system-mt-s
-- [ C:/msys64/mingw64/share/cmake/Modules/FindBoost.cmake:2311 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-mgw13-mt-d-1_82;libboost_system-mgw13-mt-d;libboost_system-mgw13-mt-d;libboost_system-mt-d-1_82;libboost_system-mt-d;libboost_system-mt-d;libboost_system-mt;libboost_system;libboost_system-mgw13-mt-s-d-1_82;libboost_system-mgw13-mt-s-d;libboost_system-mgw13-mt-s-d;libboost_system-mt-s-d-1_82;libboost_system-mt-s-d;libboost_system-mt-s-d
-- [ C:/msys64/mingw64/share/cmake/Modules/FindBoost.cmake:807 ] Boost_LIBRARY_DIR_DEBUG = "C:/boost_1_82_0/stage/lib"
-- [ C:/msys64/mingw64/share/cmake/Modules/FindBoost.cmake:809 ] _boost_LIBRARY_SEARCH_DIRS_DEBUG = "C:/boost_1_82_0/stage/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH"
**!!!!!!!---------- same for thread, regex, chrono and atomic ----------!!!!!!!**
-- [ C:/msys64/mingw64/share/cmake/Modules/FindBoost.cmake:807 ] Boost_LIBRARY_DIR_DEBUG = "C:/boost_1_82_0/stage/lib"
-- [ C:/msys64/mingw64/share/cmake/Modules/FindBoost.cmake:809 ] _boost_LIBRARY_SEARCH_DIRS_DEBUG = "C:/boost_1_82_0/stage/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH"
**CMake Error at C:/msys64/mingw64/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Boost (missing: system thread regex) (found suitable version
"1.82.0", minimum required is "1.82.0")
Call Stack (most recent call first):
C:/msys64/mingw64/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
C:/msys64/mingw64/share/cmake/Modules/FindBoost.cmake:2377 (find_package_handle_standard_args)
CMakeLists.txt:31 (find_package)**
In the directory (C:\boost_1_82_0\stage\lib) I got all my libs in the following format
libboost_atomic-mgw13-mt-d-x64-1_82.a
libboost_atomic-mgw13-mt-sd-x64-1_82.a
libboost_atomic-mgw13-mt-s-x64-1_82.a
libboost_atomic-mgw13-mt-x64-1_82.a
All of this is working on my Ubuntu. But on my Window (OS) it's not working ... If anyone could help me It would be amazing.
PS - 1: When I alter the CMake to become
target_include_directories(${PROJECT_NAME} PUBLIC "C:/boost_1_82_0")
target_link_libraries(${PROJECT_NAME}
"C:/boost_1_82_0/stage/lib/libboost_system-mgw13-mt-d-x64-1_82.a"
"C:/boost_1_82_0/stage/lib/libboost_thread-mgw13-mt-d-x64-1_82.a"
"C:/boost_1_82_0/stage/lib/libboost_regex-mgw13-mt-d-x64-1_82.a"
"C:/boost_1_82_0/stage/lib/libboost_chrono-mgw13-mt-d-x64-1_82.a"
"C:/boost_1_82_0/stage/lib/libboost_atomic-mgw13-mt-d-x64-1_82.a")
It works but I would like to make it work with find_package