could not find the following boost libraries - boost

I am not able to figure out why am I getting this error.
CMake Error at C:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:1753 (message):
Unable to find the requested Boost libraries.
Boost version: 1.48.0
Boost include path: D:/Shark/boost_1_48_0
Could not find the following Boost libraries:
boost_system
boost_date_time
boost_filesystem
boost_program_options
boost_serialization
boost_thread
boost_unit_test_framework
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.
Call Stack (most recent call first):
CMakeLists.txt:146 (find_package)
CMake Error at CMakeLists.txt:154 (message):
Please make sure Boost 1.48.0 is installed on your system
It says, Unable to find requested boost library. But I have installed boost 1.48.0 and build it using Visual studio console, and have passed BOOST_LIBRARYDIR=D:/Shark/boost_1_48_0/stage/lib and BOOST_ROOT=D:/Shark/boost_1_48_0.

CMake's FindBoost macros look for the libs in various spots based on the compiler your using. Even if you specify BOOST_LIBRARYDIR, you still have to conform to the standards the FindBoost macro expects for filenames ie:
${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
${Boost_LIB_PREFIX}boost_${COMPONENT} )
Example filenames matching this template for visual studio 2013 (aka msvc 12)
$BOOST_LIBRARY_DIR/boost_atomic-vc120-mt-1_58.dll
$BOOST_LIBRARY_DIR/boost_atomic-vc120-mt-gd-1_58.dll
You'll note that the mt for multithreaded build and the gd to indicate it's a debug build. FindBoost is fussy and will look for the debug build if your CMake project has a CMAKE_BUILD_TYPE=Debug
Additionally if your building multithreaded you'll need to define:
Boost_USE_MULTITHREADED=ON
If your still having trouble you define: Boost_DEBUG=1 and you'll see a lot of additional output about how and where FindBoost is searching.

I was building the boost library by downloading source file. The problem was it was not creating .dll (only .lib).
I downloaded boost binary and installed it from installer to get those files, and set the path BOOL_LIBRARYDIR=C:/local/boost/lib64-msvc-14.0 and BOOL_ROOT=C:/local/boost to make it done.

Related

Cmake won't find correct version of Boost

I am trying to build some code using cmake. The code uses some Boost libraries. Because of that I try to find Boost in the cmakefile:
find_package(Boost 1.65.1 REQUIRED COMPONENTS unit_test_framework program_options )
I have installed boost version 1.58 via apt (I am using Linux Mint 18.3), so I obviously get the error message when trying to cmake the code:
CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message):
Unable to find the requested Boost libraries.
Boost version: 1.58.0
Boost include path: /usr/include
Detected version of Boost is too old. Requested version was 1.65.1 (or newer).
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)
-- Configuring incomplete, errors occurred!
So I went on and downloaded Boost 1.65.1 by source and built it the intended way and installed it with the prefix
sudo ./b2 install --prefix=/usr/include
When I try to build the code again, it still gives the exact same error message as before, stating that it didn't find the newer version. I have tried to uninstall version 1.58 and build, but then cmake doesn't find Boost at all.
How can I install Boost in a way, that cmake is able to find it?
Thanks in advance,
cheers!
When changing the version information of Boost in a find_package(Boost) call you need to clear the CMakeCache.txt file. Otherwise the cached information from the previous run is used.

Cmake can find boost but not boost core

I have installed the libboost-all-dev packaged on Ubuntu.
Cmake 3.10.2 can find boost but not "boost_core".
When I change the find package line to:
find_package(Boost REQUIRED COMPONENTS core)
Then it complains that it can't find "boost_core".
I actually just need boost/iterator...
How to make cmake find that?
Thanks.
CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(test_boost_iterator)
set(CMAKE_CXX_STANDARD 11)
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
add_definitions( "-DHAS_BOOST" )
add_executable(test_boost_iterator main.cpp)
Success message (before replacing the find_package line):
-- Boost version: 1.65.1
-- Configuring done
-- Generating done
Error message (after replacing the find_package line)
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_core
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.
Call Stack (most recent call first):
CMakeLists.txt:6 (find_package)
As I know there is no such a boost library core. You can check if a library should be linked here.
And Boost.Iterator is a header-only library, so you don't need to link anything. Just include <boost/iterator/...>. If you can't include, check whether these includes actually exist in your local boost distro.
I checked it for boost::counting_iterator<int> and all works well for me.

Error on compile tibia source

I'm trying compile tibia server with CMake 3.1.3 but I'm getting the following error:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindBoost.cmake:1182 (message):
Unable to find the requested Boost libraries.
Boost version: 1.57.0
Boost include path: C:/Users/maria de lourdes/Downloads/boost_1_57_0
Could not find the following Boost libraries:
boost_thread
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:6 (find_package)
CMake Error at CMakeLists.txt:7 (find_package):
By not providing "FindGMP.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "GMP", but
CMake did not find one.
Could not find a package configuration file provided by "GMP" with any of
the following names:
GMPConfig.cmake
gmp-config.cmake
Add the installation prefix of "GMP" to CMAKE_PREFIX_PATH or set "GMP_DIR"
to a directory containing one of the above files. If "GMP" provides a
separate development package or SDK, be sure it has been installed.
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.1)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
Configuring incomplete, errors occurred!
See also "C:/Tibia/src/build/CMakeFiles/CMakeOutput.log".

Boost installation on windows, libraries missing

I am trying to build boost. I followed the instructions here. I create a folder C:\Boost which contains include and libs and I add it to my enviroment path. However, when I tried to build another project with cMake I am getting:
CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1106 (message):
Unable to find the requested Boost libraries.
Boost version: 1.55.0
Boost include path: C:/Boost/include/boost-1_55
The following Boost libraries could not be found:
boost_system
boost_filesystem
boost_signals
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.
Call Stack (most recent call first):
CMakeLists.txt:88 (find_package)
Any idea about those missing libs?
It's a bad thing to start an answer with a question, but I do it nevertheless:
First, am I right in assuming that you've set an environment variable BOOST_ROOT pointing to C:\Boost? (Simply adding it to the path might not be sufficient here.)
Second, which CMake generator are you running? Visual Studio, Makefile, ninja?
I've head a similar problem recently that was connected to the generator that I was actually using. More precisely, I was trying to create a Ninja project from within cmake-gui and got almost the same error message. However, I was able to create a Visual Studio project in cmake-gui project without problem.
When looking a little closer at the command output for the Ninja case I found the following two lines at the very beginning:
The C compiler identification is unknown
The CXX compiler identification is unknown
This hints at the actual problem. While it is clear which compiler will be in use for Visual Studio (9, 10, 11, ...), cmake cannot infer a default compiler for Ninja because it is a generic build system that runs with different compilers. In the end boost wasn't found because the compiler is unknown.
A simple solution was to open the Developer Command Prompt for the Visual Studio version that you want to run with. When you create the project in this "extended" command prompt CMake will be able to infer the correct compiler. Alternatively, you can set the CMAKE_CXX_COMPILER and CMAKE_C_COMPILER flags when running cmake.
cmake -G "Ninja" <path/to/CMakeLists.txt>
cmake -G "Ninja" <path/to/CMakeLists.txt> -DCMAKE_CXX_COMPILER="path/to/cxx/compiler" -CMAKE_C_COMPILER="path/to/c/compiler"

Cannot specify BOOST_ROOT for cmake

I have multiple versions of Boost installed (Windows 7/MinGW). I need to use a particular one (1.53.0).
I defined BOOST_ROOT in the CMakeFiles.txt file: SET(BOOST_ROOT C:/boost_1_53_0/), but I keep getting this error:
> cmake .
BOOST_ROOT=C:/boost_1_53_0/
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1191 (message):
Unable to find the requested Boost libraries.
Boost version: 1.48.0
Boost include path: C:/Boost/include/boost-1_48
Detected version of Boost is too old. Requested version was 1.53 (or
newer).
The following Boost libraries could not be found:
boost_filesystem
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.
I also defined BOOST_ROOT as an environment variable, but with the same result.
Why is cmake still looking for the old version?
Try this:
cmake -DBOOST_ROOT=path
I also struggled with this same problem for a while. If this is the same issue that I had, then the problem is you aren't running the CMake configuration completely fresh without any cache. Once it runs once and finds the default installation (C:\Boost or /usr/include) it will continue to find that one regardless of the value of BOOST_ROOT. So make sure to completely delete any generated build files. Then set BOOST_ROOT to your desired separate installation and it should work fine.
This is also mentioned by jaor on the previously linked question: How can I get cmake to find my alternative boost installation?
If you are using a precompiled version of Boost libraries for Visual Studio, they come in a specific flavor of MSVC version and bitness. I needed to point CMake to that specific location - in my case, setting BOOST_ROOT to C:/local/boost_1_59_0 and BOOST_LIBRARYDIR to C:/local/boost_1_59_0/lib64-msvc-11.0 helped.

Resources