1

I'm trying to add Boost to my C++ project using CMake but it refuses to find Boost libraries eventhough I am 100% sure they are there.

Error:Unable to find the requested Boost libraries.
Boost version: 1.61.0
Boost include path: C:/Program Files (x86)/boost_1_61_0
Could not find the following Boost libraries:
        boost_system
No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.

This is what my search looks like in CMake.

FIND_PACKAGE(Boost REQUIRED COMPONENTS system)
IF (Boost_FOUND)
    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
    ADD_DEFINITIONS( "-DHAS_BOOST" )
ENDIF()

I have tried to set all of the paths manually but nothing changes and it keeps telling me no libraries could be found.

EDIT: To clarify, if I remove "COMPONENTS system" it will not error but crash on the build, giving

"undefined reference to `boost::system::generic_category()'"

, etc.

EDIT 2: I want to clarify a bit more, I am able to use header only parts of boost, but I cannot use anything else, as it will give me the undefined reference error. I searched Stackoverflow for that error, and the solution was adding the "COMPONENTS system" part to find_package, and that's where it goes wrong.

RayShawnOfNapalm
  • 210
  • 6
  • 20
  • Based on what information did you conclude that you are "100% sure they" are installed? – Sam Varshavchik Jun 19 '16 at 20:00
  • Because I took whats in the rar, and put it there maybe? – RayShawnOfNapalm Jun 19 '16 at 20:05
  • 3
    Are you sure that you get **exactly** that libraries, which are **suited for build system** you use? There are different libraries for use with MinGW, Visual Studio. And even different versions of Visual Stidio require different Boost libraries. Insert line `set(BOOST_DEBUG)` before `find_package()` call, and CMake will outputs precize names of library files which it searches(with suffixes dependent on your build system). Check that you have exactly that library files. – Tsyvarev Jun 19 '16 at 20:18
  • 1
    Have you set the BOOST_ROOT environment variable before calling Cmake? Should you set Boost_USE_STATIC_LIBS? Have you cleared your Cmake cache? – André Jun 20 '16 at 00:08
  • 1
    Possible duplicate of [Cmake doesn't find Boost](http://stackoverflow.com/questions/3808775/cmake-doesnt-find-boost) – André Jun 20 '16 at 00:13
  • @Andre Not actually, I used the solution for that answer, and it doesn't work for me. – RayShawnOfNapalm Jun 20 '16 at 06:51

0 Answers0