I'm trying to build a CMake project on CentOS 5 using a built-from-source version of Boost. I have installed Boost 1.74.0 in /tmp/boost/boost_1_74_0. In my CMakeLists.txt I try to find this installation with find_package(Boost 1.72 REQUIRED COMPONENTS graph). I also pass -DBOOST_ROOT=/tmp/boost/boost_1_74_0 to cmake.
The call to find_package ostensibly succeeds. However, Boost_INCLUDE_DIR is subsequently still set to Boost_INCLUDE_DIR-NOTFOUND. I do not understand why or how this happens, the project builds on several other systems on which I have installed Boost via a package manager. Even when I symlink or copy /tmp/boost/boost_1_74_0/boost to /usr/include, CMake is still unable to set Boost_INCLUDE_DIR. What could be the issue here?
Here's what CMake outputs when I also specify -DBoost_DEBUG=ON:
-- Finding boost...
-- Found Boost 1.74.0 at /usr/lib/cmake/Boost-1.74.0
-- Requested configuration: QUIET REQUIRED COMPONENTS graph
-- BoostConfig: find_package(boost_headers 1.74.0 EXACT CONFIG REQUIRED QUIET HINTS /usr/lib/cmake)
-- Found boost_headers 1.74.0 at /usr/lib/cmake/boost_headers-1.74.0
-- BoostConfig: find_package(boost_graph 1.74.0 EXACT CONFIG REQUIRED QUIET HINTS /usr/lib/cmake)
-- Found boost_graph 1.74.0 at /usr/lib/cmake/boost_graph-1.74.0
-- Boost toolset is gcc8 (GNU 8.3.1)
-- Scanning /usr/lib/cmake/boost_graph-1.74.0/libboost_graph-variant*.cmake
-- Including /usr/lib/cmake/boost_graph-1.74.0/libboost_graph-variant-shared.cmake
-- [x] libboost_graph.so.1.74.0
-- Including /usr/lib/cmake/boost_graph-1.74.0/libboost_graph-variant-static.cmake
-- [ ] libboost_graph.a
-- Adding boost_graph dependencies: regexheaders
-- Found boost_regex 1.74.0 at /usr/lib/cmake/boost_regex-1.74.0
-- Boost toolset is gcc8 (GNU 8.3.1)
-- Scanning /usr/lib/cmake/boost_regex-1.74.0/libboost_regex-variant*.cmake
-- Including /usr/lib/cmake/boost_regex-1.74.0/libboost_regex-variant-shared.cmake
-- [x] libboost_regex.so.1.74.0
-- Including /usr/lib/cmake/boost_regex-1.74.0/libboost_regex-variant-static.cmake
-- [ ] libboost_regex.a
-- Adding boost_regex dependencies: headers
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Boost_INCLUDE_DIR
Boost_INCLUDE_DIR is a variable that can be specified as input to the FindBoost.cmake module to lookup a Boost installation. You are more likely to be interested in Boost_INCLUDE_DIRS variable (note the trailing S) that is populated by the FindBoost.cmake module. See documentation for further information.
I am trying to compile libgit2 and followed the instruction on https://libgit2.github.com/docs/guides/build-and-link/ but lock so far.
Can someone tell me what to do?
Here is the result from my command line:
-- Building for: Visual Studio 12 2013
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- zlib was not found; using bundled 3rd-party sources.
-- LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.
CMake Error at d:/cmake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
Call Stack (most recent call first):
d:/cmake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
d:/cmake/share/cmake-3.3/Modules/FindPythonInterp.cmake:162 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:594 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
See also "D:/temp/gitlib/libgit2-master/build/CMakeFiles/CMakeOutput.log".
See also "D:/temp/gitlib/libgit2-master/build/CMakeFiles/CMakeError.log".
Thanks,
libgit2 uses python (works both with versions 2 and 3 of the language) to build the tests. You can install python or ask CMake not to build the tests.
IIRC CMake will look in a few standard locations you don't necessarily need python in your path, though it doesn't hurt.
If you would rather not build the tests, you can pass -DBUILD_CLAR=OFF so it doesn't bother looking for python.
Download Python from Paython.org and install it (i.e. d:\python). Then Open your VS command line and type PATH D:\Python\Python35-32;d:\cmake\bin;%PATH%
That's all set now, go to your build folder run cmake .. and then cmake --build .
I have a problem with Qt binding for Gstreamer. Im using procedure from README from QtGStreamer package but I get some error while executing cmake command.
Basic info:
Mac OS X v. 10.6.8
GStreamer v. 0.10.36 + dependencies (installed through MacPorts)
Cmake v. 2.8.10 + dependencies (installed through MacPorts)
Boost v. 1.52.0 + dependencies (installed through MacPorts)
Qt v 4.8 (installed through SDK installer)
Sugested build procedure:
$ mkdir build && cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/installation/prefix
$ make
$ make install
Result of cmake:
$ cmake .. -DCMAKE_INSTALL_PREFIX=/tmp1/install
-- The C compiler identification is GNU 4.2.1
-- The CXX compiler identification is GNU 4.2.1
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - not found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - found
-- Looking for QT_MAC_USE_COCOA
-- Looking for QT_MAC_USE_COCOA - found
-- Found Qt4: /opt/local/bin/qmake (found version "4.8.4")
-- Boost version: 1.52.0
-- Found PkgConfig: /opt/local/bin/pkg-config (found version "0.27.1")
-- checking for module 'gstreamer-0.10'
-- found gstreamer-0.10, version 0.10.36
-- checking for module 'gstreamer-base-0.10'
-- found gstreamer-base-0.10, version 0.10.36
-- Found GSTREAMER_BASE_LIBRARY: /opt/local/lib/libgstbase-0.10.dylib
-- Found GSTREAMER_BASE_INCLUDE_DIR: /Library/Frameworks/GStreamer.framework/Headers/gst/base
-- Found GStreamer: /opt/local/lib/libgstreamer-0.10.dylib (Required is at least version "0.10.33")
-- checking for module 'gstreamer-plugins-base-0.10'
-- package 'gstreamer-plugins-base-0.10' not found
-- checking for module 'gstreamer-app-0.10'
-- package 'gstreamer-app-0.10' not found
-- Could NOT find GSTREAMER_APP_LIBRARY
-- Found GSTREAMER_APP_INCLUDE_DIR: /Library/Frameworks/GStreamer.framework/Headers/gst/app
-- checking for module 'gstreamer-interfaces-0.10'
-- package 'gstreamer-interfaces-0.10' not found
-- Could NOT find GSTREAMER_INTERFACES_LIBRARY
-- Found GSTREAMER_INTERFACES_INCLUDE_DIR: /Library/Frameworks/GStreamer.framework/Headers/gst/interfaces
-- checking for module 'gstreamer-video-0.10'
-- package 'gstreamer-video-0.10' not found
-- Could NOT find GSTREAMER_VIDEO_LIBRARY
-- Found GSTREAMER_VIDEO_INCLUDE_DIR: /Library/Frameworks/GStreamer.framework/Headers/gst/video
-- Could NOT find GStreamerPluginsBase (missing: GSTREAMER_APP_LIBRARY GSTREAMER_INTERFACES_LIBRARY GSTREAMER_VIDEO_LIBRARY) (Required is at least version "0.10.33")
-- checking for module 'glib-2.0'
-- found glib-2.0, version 2.34.3
-- Found GLIB2: /opt/local/lib/libglib-2.0.dylib
-- checking for module 'gobject-2.0'
-- found gobject-2.0, version 2.34.3
-- Found GObject: /Library/Frameworks/GStreamer.framework/Headers/gobject
-- Found OpenGL: /System/Library/Frameworks/OpenGL.framework
-- Could NOT find OpenGLES2 (missing: OPENGLES2_INCLUDE_DIR OPENGLES2_LIBRARY)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-----------------------------------------------------------------------------
-- The following external packages were located on your system.
-- This installation will have the extra features provided by these packages.
----------------------------------------------------------------------------- * Qt 4 - Required for building everything * QtOpenGL - Required for OpenGL acceleration in qtvideosink and QtGStreamerUi * QtDeclarative - Required for building QML support * Boost - Required for building QtGLib * GStreamer - Required to build QtGStreamer * GStreamer base library - Used for building the qwidgetvideosink element * GLib - Required to build QtGLib * GObject - Required to build QtGLib * OpenGL - Required for OpenGL rendering support in qtvideosink (desktop only)
-----------------------------------------------------------------------------
-- The following OPTIONAL packages could NOT be located on your system.
-- Consider installing them to enable more features from this software.
----------------------------------------------------------------------------- * GStreamer video library (0.10.33 or higher)
Used for building the qwidgetvideosink element * OpenGLES (2.0 or higher)
Required for OpenGLES rendering support in qtvideosink (embedded only) * Doxygen
Used to generate the API documentation
-----------------------------------------------------------------------------
-- The following REQUIRED packages could NOT be located on your system.
-- You must install these packages before continuing.
----------------------------------------------------------------------------- * GStreamer app library (0.10.33 or higher)
Required to build QtGStreamerUtils * GStreamer interfaces library (0.10.33 or higher)
Required to build QtGStreamer
-----------------------------------------------------------------------------
CMake Error at cmake/modules/MacroLogFeature.cmake:141 (MESSAGE): Exiting: Missing Requirements Call Stack (most recent call first): CMakeLists.txt:152 (macro_display_feature_log)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: GSTREAMER_APP_LIBRARY (ADVANCED)
linked by target "QtGStreamerUtils" in directory /Users/madman/Downloads/RELEASE-0.10.2/src/QGst GSTREAMER_INTERFACES_LIBRARY (ADVANCED)
linked by target "QtGStreamer" in directory /Users/madman/Downloads/RELEASE-0.10.2/src/QGst
-- Configuring incomplete, errors occurred!
I need this binding to develop an app for playing MJPEG/ASF streams from CCTV cameras. I have tried libvlc already but there is no easy way to capture streams while they are already displayed... GStreamer is the only alternative because it's gonna be cross platform application
I'm fairly new to C++/Qt programming and whole build/compile magic is still little bit confusing for me...
I know there is no simple answer how to build QtGstreamer binding but I'm gonna be very grateful for any help
I am trying to build the boost::locale library (http://cppcms.sourceforge.net/boost_locale/html/tutorial.html#a5771bce93e200c36f7cd9dfd0e5deaa) which is still in review for integration into boost but the cmake command throws up the following:
D:\lib\boost_locale_v2.92\build>cmake ..
-- Looking for ICU libraries
-- Looking for iconv
-- Looking for Boost
CMake Error: The following variables are used in this project, but they are se
to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake fi
s:
BOOST_THREAD
linked by target "boost_locale-static" in directory D:/lib/boost_locale_v2
2
ICU_DATA
linked by target "boost_locale-static" in directory D:/lib/boost_locale_v2
2
ICU_I18N
linked by target "boost_locale-static" in directory D:/lib/boost_locale_v2
2
ICU_INCLUDE_DIR
used as include directory in directory D:/lib/boost_locale_v2.92
ICU_UC
linked by target "boost_locale-static" in directory D:/lib/boost_locale_v2
2
-- Configuring incomplete, errors occurred!
I have got ICU and boost but can't figure out how to modify the out-of-box cmake script for boost::locale. Any help is appreciated
Actually these error messages are clear enough. You need to point where is what: boost thread library location, ICU include directory, and others.
Read the installation instructions carefully:
http://cppcms.sourceforge.net/boost_locale/html/building_boost_locale.html
You need to provide:
cmake -DCMAKE_INCLUDE_PATH=/path/to/boost/include;path/to/icu/include -DCMAKE_LIBRARY_PATH=/path/to/icu/lib ..
I'm trying to configure a project using CMake, but it fails to find Boost libraries even though they are in the specified folder. I have specified Boost_INCLUDE_DIR, Boost_LIBRARYDIR and BOOST_ROOT , but I still get an error saying that CMake is not able to find Boost. What could be the reason of such error?
Are you sure you are doing it the correct way? The idea is that CMake sets BOOST_INCLUDE_DIR, BOOST_LIBRARYDIR and BOOST_ROOT automatically. Do something like this in CMakeLists.txt:
FIND_PACKAGE(Boost)
IF (Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
ADD_DEFINITIONS( "-DHAS_BOOST" )
ENDIF()
If boost is not installed in a default location and can, thus, not be found by CMake, you can tell CMake where to look for boost like this:
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/win32libs/boost")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/win32libs/boost/lib")
Of course, those two lines have to be before the FIND_PACKAGE(Boost) in CMakeLists.txt.
There is more help available by reading the FindBoost.cmake file itself. It is located in your 'Modules' directory.
A good start is to set(Boost_DEBUG 1) - this will spit out a good deal of information about where boost is looking, what it's looking for, and may help explain why it can't find it.
It can also help you to figure out if it is picking up on your BOOST_ROOT properly.
FindBoost.cmake also sometimes has problems if the exact version of boost is not listed in the Available Versions variables. You can find more about this by reading FindBoost.cmake.
Lastly, FindBoost.cmake has had some bugs in the past. One thing you might try is to take a newer version of FindBoost.cmake out of the latest version of CMake, and stick it into your project folder alongside CMakeLists.txt - then even if you have an old version of boost, it will use the new version of FindBoost.cmake that is in your project's folder.
Good luck.
For me this error was simply because boost wasn't installed so on ubuntu:
sudo apt install build-essential libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-test-dev
I struggled with this problem for a while myself. It turned out that cmake was looking for Boost library files using Boost's naming convention, in which the library name is a function of the compiler version used to build it. Our Boost libraries were built using GCC 4.9.1, and that compiler version was in fact present on our system; however, GCC 4.4.7 also happened to be installed. As it happens, cmake's FindBoost.cmake script was auto-detecting the GCC 4.4.7 installation instead of the GCC 4.9.1 one, and thus was looking for Boost library files with "gcc44" in the file names, rather than "gcc49".
The simple fix was to force cmake to assume that GCC 4.9 was present, by setting Boost_COMPILER to "-gcc49" in CMakeLists.txt. With this change, FindBoost.cmake looked for, and found, my Boost library files.
You can also specify the version of Boost that you would like CMake to use by passing -DBOOST_INCLUDEDIR or -DBOOST_ROOT pointing to the location of correct version boost headers
Example:
cmake -DBOOST_ROOT=/opt/latestboost
This will also be useful when multiple boost versions are on the same system.
I also had a similar problem and discovered that the BOOST_INCLUDE_DIR, BOOST_LIBRARYDIR and BOOST_ROOT env variables must hold absolute paths.
HTH!
In my case Boost was not installed. I used below command on Mac and then cmake find_package(Boost) works like a charm
brew install Boost
Please note upper case 'B' in Boost!
If you are building your own boost do not forget to use the --layout=versioned otherwise the search for a particular version of library will fail
For cmake version 3.1.0-rc2 to pick up boost 1.57 specify -D_boost_TEST_VERSIONS=1.57
cmake version 3.1.0-rc2 defaults to boost<=1.56.0 as is seen using -DBoost_DEBUG=ON
cmake -D_boost_TEST_VERSIONS=1.57 -DBoost_DEBUG=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
One more bit of advice for anyone trying to build CGAL in particular, with statically linked Boost. It is not enough to define Boost_USE_STATIC_LIBS; it gets overridden by the time Boost_DEBUG outputs its value. The thing to do here is to check the "Advanced" checkbox and to enable CGAL_Boost_USE_STATIC_LIBS.
I had the same problem while trying to run make for a project after installing Boost version 1.66.0 on Ubuntu Trusty64. The error message was similar to (not exactly like) this one:
CMake Error at
/usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/FindBoost.cmake:1245 (message):
Unable to find the requested Boost libraries.
Boost version: 0.0.0
Boost include path: /usr/include
Detected version of Boost is too old. Requested version was 1.36 (or newer).
Call Stack (most recent call first):
CMakeLists.txt:10 (FIND_PACKAGE)
Boost was definitely installed, but CMake couldn't detect it. After spending plenty of time tinkering with paths and environmental variables, I eventually ended up checking cmake itself for options and found the following:
--check-system-vars = Find problems with variable usage in system files
So I ran the following in the directory at issue:
sudo cmake --check-system-vars
which returned:
Also check system files when warning about unused and uninitialized variables.
-- Boost version: 1.66.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- thread
-- date_time
-- chrono
-- regex
-- serialization
-- program_options
-- Found Git: /usr/bin/git
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/myproject
and resolved the issue.
See FindBoost.cmake first. The variables you set are the correct ones but they should be all uppercase.
Make sure the library architecture matches with CMake configuration.
cmake -A x64 ..
I suggest creating a minimal executable which only includes a Boost library to see if it compiles.
#include <iostream>
#include <boost/date_time.hpp>
int main() {
using namespace std;
using namespace boost::gregorian;
date today = day_clock::local_day();
cout << today << endl;
}
find_package(Boost REQUIRED COMPONENTS
date_time
)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
add_executable(test_boost "test_boost.cpp")
target_link_libraries(test_boost Boost::date_time)
Start debugging by checking Boost_FOUND first.
message(STATUS "Boost_FOUND: ${Boost_FOUND}")
The version should be found even if no libraries are found. (Boost_VERSION)
If Boost_LIBRARY_DIRS becomes non-empty, it should compile.
I had the same problem, and none of the above solutions worked. Actually, the file include/boost/version.hpp could not be read (by the cmake script launched by jenkins).
I had to manually change the permission of the (boost) library (even though jenkins belongs to the group, but that is another problem linked to jenkins that I could not figure out):
chmod o+wx ${BOOST_ROOT} -R # allow reading/execution on the whole library
#chmod g+wx ${BOOST_ROOT} -R # this did not suffice, strangely, but it is another story I guess
This can also happen if CMAKE_FIND_ROOT_PATH is set as different from BOOST_ROOT.
I faced the same issue that in spite of setting BOOST_ROOT, I was getting the error.
But for cross compiling for ARM I was using Toolchain-android.cmake in which I had (for some reason):
set(BOOST_ROOT "/home/.../boost")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${SYSROOT}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/include/libcxx")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
set(CMAKE_FIND_ROOT_PATH "${SYSROOT}")
CMAKE_FIND_ROOT_PATH seems to be overriding BOOST_ROOT which was causing the issue.
For those using python3.7 docker image, this solved:
apt install libboost-system-dev libboost-thread-dev
Maybe
brew install boost
will help you.