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!
Related
I followed the instructions here:
https://github.com/xianyi/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio
for building and installing OpenBLAS, specifically 1. "Native (MSVC) ABI".
And now all the includes and libraries and CMake files are in C:/opt like it wanted.
I then saw I could use FindBLAS in my project's CMakeFile so I added
FindBLAS(), but apparently it's not a command?
I saw everyone who mentioned FindBLAS instead wrote:
set(BLA_VENDOR OpenBLAS)
find_package(BLAS REQUIRED)
so I'm actually pretty confused. What is FindBLAS? Why can't I find any examples of anyone using it?
But then I tried the set and find_package route I saw everywhere and got:
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.25/Modules/FindBLAS.cmake:1346 (find_package_handle_standard_args)
I tried setting the environment variables, resetting, everything I can think of. I'm not sure why CMake refuses to find the library and update ${BLAS_LIBRARIES}.
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.
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 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.
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.