I'm using Boost 1.79 and Windows 10. For building Boost libs I use TDM MinGW. After trying to build my test program with CMake, I get next error:
CMake Error at D:/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Boost (missing: log thread) (found suitable version
"1.79.0", minimum required is "1.79")
Call Stack (most recent call first):
D:/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
D:/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
CMakeLists.txt:16 (find_package)
My CMakeLists.txt
:
cmake_minimum_required(VERSION 3.24)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_C_COMPILER "D:/TDM-MinGW/bin/gcc.exe")
#set(CMAKE_CXX_COMPILER "D:/TDM-MinGW/bin/g .exe")
set(Boost_DEBUG=ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
project (testlib)
find_package(Boost 1.79 COMPONENTS log thread REQUIRED)
IF(Boost_FOUND)
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR})
LINK_DIRECTORIES(${Boost_LIBRARY_DIR})
MESSAGE("Boost information")
MESSAGE("Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
MESSAGE("Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
MESSAGE("Boost_Version: ${Boost_VERSION}")
MESSAGE("Boost Libraries: ${Boost_LIBRARIES}")
ENDIF()
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
add_executable(testlib src/main.cpp)
target_link_libraries(testlib PUBLIC ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
Boost libs were compiled by following command:
./b2 --build-type=complete -j 8 variant=debug address-model=64 link=static toolset=gcc install
CodePudding user response:
Well, I solve my problem by setting Boost_DEBUG
to ON
. After analyzing debug info it became clear that the problem was two empty variables: Boost_COMPILER
and Boost_ARCHITECTURE
. And to solve the problem i just set these variables by looking at the full filename, for example:
We have filename libboost_log-clang14-mt-x32-1_79.lib
, and we need this parts: -clang14
and -x32
. You should look at this parts at your filename and set this parts as CMake variables:
Boost_ARCHITECTURE
= -x32
Boost_COMPILER
= -clang14