juzzlin
juzzlin

Reputation: 47875

Why CMake cannot find my Boost libraries on Ubuntu 18.04?

This is driving me nuts. In my CMakeLists.txt I have:

find_package(Boost 1.63.0 REQUIRED SYSTEM)

Result:


[0/1] Re-running CMake...
Build type: Release
CMake Error at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1947 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.65.1

  Boost include path: /usr/include

  Could not find the following Boost libraries:

          boost_system

But:

$ locate libboost_system
/usr/lib/x86_64-linux-gnu/libboost_system.a
/usr/lib/x86_64-linux-gnu/libboost_system.so
/usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1

And:

$ sudo apt install libboost-all-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libboost-all-dev is already the newest version (1.65.1.0ubuntu1).

I have previously used a self-compiled 1.63.0, but I have removed all the files from /usr/local/lib and /usr/local/include. Maybe it still somehow haunts here..?

If I find Boost like this (without system):

find_package(Boost 1.63.0 REQUIRED)

..then configuring succeeds, but won't link to ${Boost_SYSTEM_LIBRARY}:

/usr/bin/ld: src/app/CMakeFiles/app.dir/application.cpp.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
//usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Upvotes: 1

Views: 2209

Answers (1)

juzzlin
juzzlin

Reputation: 47875

The problem was that you should require system instead of SYSTEM even though it complains about missing boost_system also when SYSTEM was used. I find that a bit confusing:

find_package(Boost 1.63.0 REQUIRED system)

Upvotes: 1

Related Questions