[英]find_package of cmake cannot find boost
I have referred to this link and made a CMakeLists.txt with following data: 我已经参考了这个链接并使用以下数据制作了一个CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
SET(TARGET integrity_scanner)
message("\nBuilding ${TARGET}")
project (${TARGET})
if (UNIX)
message(STATUS "Setting GCC flags")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -O0")
else()
message(STATUS "Setting MSVC flags")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHc-")
endif ()
include_directories ("${PROJECT_SOURCE_DIR}")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_ROOT C:/boost_1_55_0_dyn)
find_package(Boost 1.55.0 COMPONENTS thread)
SET(SOURCE
IntegrityScanner.cpp
)
SET(HEADERS
IntegrityScanner.h ../BaseApplication.hpp
)
if(Boost_FOUND)
add_definitions(-DDLL_EXPORTS)
add_definitions(-DBOOST_ALL_DYN_LINK)
include_directories("..\\..\\..\\ext_library\\zmq\\zeromq-4.0.3\\include")
include_directories("..\\..\\..\\ext_library\\zmq\\czmq\\czmq-2.1.0\\include")
link_directories("..\\..\\..\\ext_library\\zmq\\zeromq-4.0.3\\lib\\Win32\\Debug")
link_directories("..\\..\\..\\ext_library\\zmq\\czmq\\czmq-2.1.0\\lib\\Win32\\DebugDLL")
include_directories(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
add_library(${TARGET} SHARED ${SOURCE} ${HEADERS})
target_link_libraries(${TARGET} ${Boost_LIBRARIES} czmq libzmq)
else()
message(STATUS "Boost_FOUND False")
endif()
Even though I have set BOOST_ROOT , it fails and gives the Boost Found False Message. 即使我设置了BOOST_ROOT ,它也会失败并给出Boost Found False Message。 What am I doing wrong here?
我在这做错了什么?
Edit: I have found that setting Boost_USE_STATIC_LIBS to OFF is resolving the issue. 编辑:我发现将Boost_USE_STATIC_LIBS设置为OFF正在解决问题。 But I have to have it ON .
但我必须把它打开 。 What could be wrong here?
这可能有什么问题?
Your directory structure needs to look like this: 您的目录结构需要如下所示:
c:/boost/boost_1_55_0
and BOOST_ROOT is an environment variable set to c:/boost 和BOOST_ROOT是一个设置为c:/ boost的环境变量
I have found the reason why this code is not working. 我找到了此代码无效的原因。 As I am giving value ON to Boost_USE_STATIC_LIBS , the result is that find_package will look for libboost_thread-vc100-mt-1_55 , which it will not find because building boost will give shared libraries as stated in this link .
正如我给值开到Boost_USE_STATIC_LIBS,结果是find_package将寻找libboost_thread-VC100-MT-1_55,它不会找到,因为建设提升会给共享库在此说明的链接 。 Refer to pic below:
请参考下面的图片:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.