Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
893 views
in Technique[技术] by (71.8m points)

visual studio 2010 - find_package() doesn't detect boost on Windows Cmake

I'm using a windows system. I want to use the Boost library using CMake. I've installed boost on C:oost_1_55_0 Here is my CMakeLists.txt file

set(Boost_USE_STATIC_LIBS        ON)
set(Boost_USE_MULTITHREADED      ON)
set(Boost_USE_STATIC_RUNTIME    OFF)
find_package(Boost 1.55.0 COMPONENTS thread)

if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS}) 
    LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
    add_executable (linking_with_boost main.cc sqr.cc)
    target_link_libraries(linking_with_boost ${Boost_LIBRARIES})
else()
    message(STATUS "Fail  asdasd!")
endif()

I'm getting --Could NOT find Boost Output:

$ cmake ../
-- Could NOT find Boost
-- Fail  asdasd!
-- Configuring done
-- Generating done
-- Build files have been written to: D:/ubuntu_share/programming/C++/practice/cm
ake/linking_with_boost/build_win
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

On Windows 7 x64 I have Boost 1.58 installed to C:SDKsoost_1_58_0. In order to allow cMake to find all of the appropriate files, I had to add the following three system variables:

    BOOST_INCLUDEDIR    C:SDKsoost_1_58_0
    BOOST_LIBRARYDIR    C:SDKsoost_1_58_0lib64-msvc-12.0
    BOOST_ROOT          C:SDKsoost_1_58_0oost

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...