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.
Related
This is my cmake file:
cmake_minimum_required(VERSION 3.5.1)
set(PACKAGE_NAME "atest")
find_package(OpenSSL REQUIRED)
project(${PACKAGE_NAME} LANGUAGES C CXX)
I have a custom openssl binary that I wanna use in a folder
C:\MyOpenSSL\
C:\MyOpenSSL\include\ ... all the include files here
C:\MyOpenSSL\lib\ ... libssl.lib, libcrypto.lib and ossl_static.pdb
So when I run, CMake . -DOPENSSL_ROOT_DIR=C:\MyOpenSSL\
I get the following errors:
C:/cmake/cmake-3.22.2-win/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY) (found
version "1.1.1c")
Call Stack (most recent call first):
C:/cmake/cmake-3.22.2-win/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/cmake/cmake-3.22.2-win/share/cmake-3.22/Modules/FindOpenSSL.cmake:574 (find_package_handle_standard_args)
CMakeLists.txt:5 (find_package)
What am I missing here? Is somehow find_package found out the version v1.1.1c, but still saying it couldn't find it?
It turns out if I build and install openssl manually it works.
For whatever reason the raw lib i provided was not good enough for cmake to find it. I am still not sure why.
I'm trying to use the Armadillo library inside a CLion project on Windows 10, but when I try to build via Reload CMake Project (using the built-in CMake compiler), this error appears after a short while:
CMake Error at C:/Program Files/JetBrains/CLion 2017.2.3/bin/cmake/share/cmake-3.8/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Armadillo (missing: ARMADILLO_LIBRARY) (found version
"0.0.0")
Call Stack (most recent call first):
C:/Program Files/JetBrains/CLion 2017.2.3/bin/cmake/share/cmake-3.8/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/JetBrains/CLion 2017.2.3/bin/cmake/share/cmake-3.8/Modules/FindArmadillo.cmake:77 (find_package_handle_standard_args)
CMakeLists.txt:4 (find_package)
I've downloaded the library's content from here and moved it into a folder located at ${PROGRAM FILES}\Armadillo. To use it in my project, I used the FindArmadillo module like this:
find_package(Armadillo REQUIRED) # this is where the error occurs
include_directories(${ARMADILLO_INCLUDE_DIRS})
...
add_executable(MyProject ${SOURCE_FILES})
target_link_libraries(MABE ${ARMADILLO_LIBRARIES})
Is there something I am missing? Do I have to compile the library (or something like that) before I can use it in my project? Or did I maybe mess up the download?
Thanks in advance!
not sure if this is still relevant, but for a small project you can save your unzipped files in your project root directory and then add this line to your CMakeLists.txt:
target_include_directories(YOURPROJECTNAME PUBLIC armadillo/include)
I am just a beginner and found this to be the easiest solution to add many libraries :)
Hope this helps!
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).
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 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.