I'm using cmake and Visual Studio 2019 to build my project. My boost version is 1.72 and I generated file libboost_python27-vc142-mt-x64-1_72.lib
in directory boost_1_72_0\stage\lib
with b2.exe
.
I generated .sln
file with cmake. Then I build the project in Visual Studio 2019. However,
it ended up with an error LNK1104: cannot open file 'libboost_python27-vc142-mt-x64-1_71.lib'
I really can't understand why it asks for libboost_python of version 1_71 instead of 1_72. I never introduced a version 1.71 request in any file. So how should it be like that? And how can I make it work?
My CMakeLists.txt
file:
project(framecore)
cmake_minimum_required(VERSION 3.20)
message(STATUS "Configuring framecore")
set(Boost_USE_STATIC_LIBS ON)
# windows
if(MSVC)
# this although can be set by system variable Boost_INCLUDE_DIR etc
set(Boost_INCLUDE_DIR F:/boost_1_72_0)
set(Boost_LIBRARY_DIR F:/boost_1_72_0/stage/lib)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(PythonLibs 2.7 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
find_package(Boost REQUIRED COMPONENTS container)
find_package(Boost REQUIRED COMPONENTS python27)
file(GLOB_RECURSE SRC src/core/*.cpp
src/wraps/*.cpp)
file(GLOB_RECURSE SRC_HEADER src/core/*.hpp
src/core/*.h
src/wraps/*.hpp
src/wraps/*.h)
include_directories(src)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${PYTHON_INCLUDE_DIRS})
message(STATUS "Boost Include path: ${Boost_INCLUDE_DIRS}")
message(STATUS "Python2.7 Include path: ${PYTHON_INCLUDE_DIRS}")
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_PYTHON_STATIC_LIB -DBOOST_USE_WINDOWS_H /bigobj")
set(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} /verbose:lib")
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build/output)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build/output)
add_library(${PROJECT_NAME} SHARED ${SRC_HEADER} ${SRC})
# set target library's prefix suffix
if(MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".pyd")
endif()
message(STATUS "Boost_PYTHON27_LIBRARY: ${Boost_PYTHON27_LIBRARY}")
# optimized;F:/boost_1_72_0/stage/lib/libboost_python27-vc142-mt-x64-1_72.lib;debug;F:/boost_1_72_0/stage/lib/libboost_python27-vc142-mt-gd-x64-1_72.lib
target_link_libraries(${PROJECT_NAME} ${Boost_PYTHON27_LIBRARY})
target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARY})
target_link_libraries(${PROJECT_NAME} ${Boost_SYSTEM_LIBRARY})
target_link_libraries(${PROJECT_NAME} ${Boost_CONTAINER_LIBRARY})
CodePudding user response:
I know the reason now. There is another boost directory with some header files in my project folder. I wrongly included the boost directory and made a dependency on boost 1.71....