I have compiled Boost from source with Visual Studio 2017, and I'm using CMake 3.9.3 to find it with the following command in my CMakeLists.txt:
find_package(Boost REQUIRED COMPONENTS filesystem)
I'm invoking CMake like this:
cmake -G "Visual Studio 15 2017" ..
-DBOOST_ROOT="C:\Users\emlai\src\libs\boost_1_65_0"
-DBOOST_LIBRARYDIR="C:\Users\emlai\src\libs\boost_1_65_0\lib64-msvc-15.0"
I get the following message:
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1902 (message):
Unable to find the requested Boost libraries.
Boost version: 1.65.0
Boost include path: C:/Users/emlai/src/libs/boost_1_65_0
Could not find the following Boost libraries:
boost_filesystem
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:31 (find_package)
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
build/cmake-modules/FindSDL2.cmake:173 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:42 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/emlai/src/zenith/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/emlai/src/zenith/build/CMakeFiles/CMakeError.log".
The output of dir C:\Users\emlai\src\libs\boost_1_65_0\lib64-msvc-15.0 shows that the filesystem libraries are in place.
I have tried all of the answers here, but without success. The same happens with the prebuilt Boost libraries downloaded from here.
How can I solve this problem?
I needed to pass -DBoost_COMPILER="-vc141" to CMake to make it work (-vc141 being the same string as in the Boost library filenames).
Related
Cloned a repository and installed the Boost library. My IDE (CLion) keeps telling me
CMake Error at C:/Program Files/JetBrains/CLion 2021.3/bin/cmake/win/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Boost (missing: regex date_time system filesystem
unit_test_framework program_options) (found version "1.67.0")
Call Stack (most recent call first):
C:/Program Files/JetBrains/CLion 2021.3/bin/cmake/win/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/JetBrains/CLion 2021.3/bin/cmake/win/share/cmake-3.21/Modules/FindBoost.cmake:2345 (find_package_handle_standard_args)
CMakeLists.txt:29 (find_package)
Prior to this, I was trying to use the most updated Boost library which led me to more errors, after changing it to the correct library, those errors went away, leaving me with this. This error also remains when trying to use the new library too.
I have tried set(BOOST_ROOT C:/local/boost_1_71_0) as was the correct answer on another similar post, yet it didn't work. I have also tried adding it to my path, which also does nothing. To note: It is strange because it says the version number of the Boost library yet it says could not be found.
I am using CLion's bundled CMake, but I also have the official CMake installed just in case. I don't think CLion's cmake is the issue.
I already read this post and it did not answer my questions: (cmake not able to find openssl)
I am working in windows 10 64 bit and I want to use boost asio with ssl support, so I installed openssl in C:\Local\OpenSSL-Win64 and I have a environment variable pointing to this.
I have this code in cmake:
file(TO_CMAKE_PATH $ENV{OPENSSL_ROOT} OPENSSL_ROOT_DIR)
message(WARNING "root: ${OPENSSL_ROOT_DIR}")
find_package(OpenSSL )
message(WARNING "OpenSSL_VERSION: ${OPENSSL_VERSION}")
message(WARNING "OpenSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message(WARNING "OpenSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
and when I run the cmake, I am getting this message:
CMake Warning at CMakeLists.txt:44 (message):
root: C:/Local/OpenSSL-Win64
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindOpenSSL.cmake:293 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:45 (find_package)
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindOpenSSL.cmake:294 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:45 (find_package)
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindOpenSSL.cmake:296 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:45 (find_package)
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindOpenSSL.cmake:298 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:45 (find_package)
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES) (found version ".0.0`")
CMake Warning at CMakeLists.txt:47 (message):
OpenSSL_VERSION: .0.0`
CMake Warning at CMakeLists.txt:48 (message):
OpenSSL_INCLUDE_DIR: C:/Local/OpenSSL-Win64/include
CMake Warning at CMakeLists.txt:49 (message):
OpenSSL_LIBRARIES: SSL_EAY_LIBRARY-NOTFOUND;LIB_EAY_LIBRARY-NOTFOUND
as it can be seen the cmake could find the environment variable which is correctly pointed to C:/Local/OpenSSL-Win64
also interestingly, it can find the include path:
CMake Warning at CMakeLists.txt:48 (message):
OpenSSL_INCLUDE_DIR: C:/Local/OpenSSL-Win64/include
but the version, and include library is not right.
is there any specific ways that I can force cmake to find the openssl?
How can I make sure that it finds the suitable static library?
Edit 1
Aftre upgrading to cmake 3.8, now, cmake can find openssl, but not its libraries. The output is as follow:
Found OpenSSL: C:/Local/OpenSSL-Win64/lib/libssl.lib (found version "1.1.0e")
CMake Warning at CMakeLists.txt:52 (message):
OpenSSL_VERSION: 1.1.0e
CMake Warning at CMakeLists.txt:53 (message):
OpenSSL_INCLUDE_DIR: C:/Local/OpenSSL-Win64/include
CMake Warning at CMakeLists.txt:54 (message):
OpenSSL_LIBRARIES:
Why libraries are not found?
Edit 2
The reason that it could not find library was that I used the variable name with a different case. The correct name is OPENSSL_LIBRARIES.
For more information read the findopenssl.cmake file as part of the cmake distribution.
More recent OpenSSL versions (the 1.1.x series I think) slightly changed the formatting of how the version number was specified in the opensslv.h header. This caused CMake's version parsing code in its FindOpenSSL.cmake module to fail, which was then fixed around CMake 3.5.0. Furthermore, from OpenSSL 1.1.0, the library names on Windows are closer to their Unix counterparts and are named libcrypto and libssl (possibly with further suffixes) instead of the old names libeay32 and ssleay32. CMake 3.7.0 contained the update to account for this library name change. As a result of these two changes and fixes, if you want to use OpenSSL 1.1.0 or later with a CMake project, you should probably be using CMake 3.7.0 or later.
We had a similar problem with cmake 2.8.12.2 and OpenSSL 1.0.2u
CMake Error at /usr/share/cmake/Modules/FindOpenSSL.cmake:278 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:169 (FIND_PACKAGE)
To find out more details, you can add "--debug-output" option to cmake command.
In our case, it helped to specify the -D_OPENSSL_VERSION on cmake command line:
OPENSSL_VER=1.0.2u
cmake ...
-DOPENSSL_ROOT_DIR=$IDIR_BASE \
-DOPENSSL_INCLUDE_DIR=$IDIR_BASE/include \
-D_OPENSSL_VERSION="$OPENSSL_VER" \
I literally spent a good 6 hours on it and looked everywhere on the internet.
Here is what I have done. I am on Windows 10 using JetBrain CLion IDE. Directly downloaded MinGW 5.3, not through CodeBlocks. Downloaded Boost 1.63 and unzipped it. Ran bootstrap.bat gcc and b2.exe toolset=gcc to build it. During installation, gcc-mingw-5.3.0 appeared tons of times so I suppose they are somehow linked now. Then a new folder C:/Boost appeared containing only two folders: include and lib.
Here is my CMakeList.txt:
cmake_minimum_required(VERSION 3.7)
project(BoostTest)
set(CMAKE_CXX_STANDARD 11)
set(Boost_INCLUDE_DIR C:/Boost/include)
set(BOOST_LIBRARY_DIR C:/Boost/lib)
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
set(SOURCE_FILES main.cpp)
add_executable(BoostTest ${SOURCE_FILES})
Since the original directory (which I unzipped from the download) does not have directories named include and lib, I figured I should go with the directory created by installation(or building). Then I get this error:
CMake Error at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1169 (file):
file STRINGS file "C:/Boost/include/boost/version.hpp" cannot be read.
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
CMake Warning at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version 0
Call Stack (most recent call first):
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:8 (find_package)
CMake Warning at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version 0
Call Stack (most recent call first):
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:8 (find_package)
CMake Error at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1793 (message):
Unable to find the requested Boost libraries.
Boost version: 0.0.0
Boost include path: C:/Boost/include
Could not find the following Boost libraries:
boost_system
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.
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Workspace_cpp/BoostTest/cmake-build-debug/CMakeFiles/CMakeOutput.log".
You see, CMake is somehow able to reach this version.hpp file, but cannot read it. I have seen quite a few people posting the same question, but none of their solutions worked for me. I have tried to set INCLUDE_DIR and LIBRARY_DIR to the original directory, and not helping a bit. I am truly frustrated. I greatly appreciate any help. Thanks!
Update:
Thank you oLen for pointing it out! It was helpful. I have updated my CMakeList.txt to be:
set(BOOST_ROOT C:/Boost)
set(BOOST_INCLUDEDIR C:/Boost/include)
set(BOOST_LIBRARYDIR C:/Boost/lib)
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
However, I am receiving a new error message:
"D:\Program Files (x86)\JetBrains\CLion 2017.1\bin\cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Workspace_cpp\BoostTest
CMake Warning at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:9 (find_package)
CMake Error at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1793 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:9 (find_package)
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 (ADVANCED)
I think it successfully located the directory but could not process it. I am sorry for keep asking, these errors make absolutely no sense to me. May I also know if I should build Boost before using it, since in the official Boost Get Started page, it does not say to build it. The error message also wants me to set BOOST_INCLUDE_DIR. Could you please shed some more light? Thank you so much.
You haven't set the variables to find Boost correctly.
If you take a look at FindBoost.cmake, you see the following:
# This module reads hints about search locations from variables::
#
# BOOST_ROOT - Preferred installation prefix
# (or BOOSTROOT)
# BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include
# BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib
# Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not
# specified by these hint variables. Default is OFF.
# Boost_ADDITIONAL_VERSIONS
# - List of Boost versions not known to this module
# (Boost install locations may contain the version)
In your case, the easiest solution is to set BOOST_ROOT to the folder containing lib and include (i.e. C:/Boost), or to use the correct variable names BOOST_INCLUDEDIR and BOOST_LIBRARYDIR (without second underscore).
The variables with the second underscore also exist, but they are set when you search for Boost.
After researching for a few days, installing and uninstalling tons of times, it turns out that I was just mistaking one line:
set(BOOST_INCLUDEDIR C:/boost/include/boost-1_63)
That is it! Oh my GOD.
Well,I am new to CMake and want to edit flight simulation code in eclipse instead of visual studio. For that purpose, I downloaded the source code of Simgear, CMake, Boost libraries, open scene graph and openalsoft.
Now I have all the data available but I dont know where to place some of these libraries. As a result, when I run CMake and give reference to my flightgear code, it complains that the openscenegraph libraries are not installed.
Please help me with where I need to put all these files so as to convert my code to eclipse using CMake. I have already installed boost and openal libraries. Only issue is of openscenegraph libraries which I put in program files at the following path "C:\Program Files\OpenSceneGraph-3.4.0" but CMake can't access it. The error code is
Eclipse version is set to 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
version is 2016 dot 3 dot 1
ignoring: ^C:/Media/Project/study material/flight gear/simgear-2016.3.1/.git;\\.gitignore;Makefile.am;~$;
Library installation directory: lib
Boost version: 1.62.0
SimGear mode: NORMAL
Found OpenAL: C:/Program Files/OpenAL/OpenAL32.lib
Sound support: ENABLED
Could NOT find osgText (missing: OSGTEXT_LIBRARY OSGTEXT_INCLUDE_DIR)
Could NOT find osgSim (missing: OSGSIM_LIBRARY OSGSIM_INCLUDE_DIR)
Could NOT find osgDB (missing: OSGDB_LIBRARY OSGDB_INCLUDE_DIR)
Could NOT find osgParticle (missing: OSGPARTICLE_LIBRARY OSGPARTICLE_INCLUDE_DIR)
Could NOT find osgGA (missing: OSGGA_LIBRARY OSGGA_INCLUDE_DIR)
Could NOT find osgViewer (missing: OSGVIEWER_LIBRARY OSGVIEWER_INCLUDE_DIR)
Could NOT find osgUtil (missing: OSGUTIL_LIBRARY OSGUTIL_INCLUDE_DIR)
Could NOT find osg (missing: OSG_LIBRARY OSG_INCLUDE_DIR)
Could NOT find OpenThreads (missing: OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR)
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find OpenSceneGraph (missing: OPENSCENEGRAPH_LIBRARIES
OPENSCENEGRAPH_INCLUDE_DIR OSGTEXT_FOUND OSGSIM_FOUND OSGDB_FOUND
OSGPARTICLE_FOUND OSGGA_FOUND OSGVIEWER_FOUND OSGUTIL_FOUND OSG_FOUND
OPENTHREADS_FOUND) (Required is at least version "3.2.0")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.7/Modules/FindOpenSceneGraph.cmake:223 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:243 (find_package)
Configuring incomplete, errors occurred!
See also "C:/Users/shajeeh/Documents/CMake/CMakeFiles/CMakeOutput.log".
I'm not a CMake expert, here some things I did in order to create ROS & OSG project in Linux:
add an environment variable (if it is not there yet) to the .bashrc file:
export PATH=${PATH}: .../OpenSceneGraph-3.4.0/bin (your absolute path)
then in CMake file add:
FIND_PACKAGE ( OpenSceneGraph COMPONENTS osgSim osgUtil osgDB osgFX osgGA osgTerrain osgViewer osgText osgWidget osgManipulator osg osgShadow)
target_link_libraries(name_of_your_executable ${PROJECT_NAME} ${OPENSCENEGRAPH_LIBRARIES})
For more information check CMake documentation here and here
I am using windows 7 - 64bit and am trying to build a project. When I use cmake i get the error
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoos
t.cmake:1191 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
src/CMakeLists.txt:310 (find_package)
CMake Error at src/CMakeLists.txt:312 (message):
Boost C++ libraries not found. Please install or try setting BOOST_ROOT
I have set the variable to BOOST_ROOT to D:\MyProject\boost_1_43_0\boost\
but i still get this . How can i resolve this issue.
Placing boost in a subfolder of the project is not standard CMake practice for locating boost. I have boost x64 - MSVC 2010 installed in Program Files and CMake automatically locates it.
Boost_DIR : C:/Program Files/Boost/share/cmake/boost
Boost_INCLUDE_DIR : C:/Program Files/Boost/include
You can attempt to set Boost_DIR at the system environment variables level as well.