I am using CMAKE to try to load Boost library into my project. (I'm using CLion as IDE). Here is my CMAKE file:
cmake_minimum_required(VERSION 3.14)
project(untitled2)
set(Boost_USE_STATIC_LIBS ON) # only find static libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_INCLUDE_DIR C/Users/User/Downloads/boost_1_68_0/boost_1_68_0/libs)
find_package(Boost 1.68.0 COMPONENTS system filesystem REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(untitled2 ${Boost_LIBRARIES})
endif()
add_executable(untitled2 main.cpp)
set(CMAKE_CXX_STANDARD 14)
Here is my directory (C/Users/User/Downloads/boost_1_68_0/boost_1_68_0/):
When reloading CMAKE file I get this error:
CMake Error at C:/Program Files/JetBrains/CLion 2019.1.4/bin/cmake/win/share/cmake-3.14/Modules/FindBoost.cmake:1388 (file):
file STRINGS file
"C:/Users/User/CLionProjects/untitled2/C/Users/User/Downloads/boost_1_68_0/boost_1_68_0/libs/boost/version.hpp"
cannot be read.
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
CMake Error at C:/Program Files/JetBrains/CLion 2019.1.4/bin/cmake/win/share/cmake-3.14/Modules/FindBoost.cmake:2147 (message):
Unable to find the requested Boost libraries.
Boost version: 0.0.0
Boost include path: C/Users/User/Downloads/boost_1_68_0/boost_1_68_0/libs
Detected version of Boost is too old. Requested version was 1.68 (or
newer).
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/User/CLionProjects/untitled2/cmake-build-debug/CMakeFiles/CMakeOutput.log".
[Failed to reload]
Any suggestions why it fails??
Related
I want to use CUDA, Boost for my application and find myself stuck with the following error message
$ cmake ..
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/BoostDetectToolset-1.71.0.cmake:5 (string):
string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to
command.
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/boost_program_options-1.71.0/boost_program_options-config.cmake:24 (include)
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package)
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
/home/long/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/211.7442.42/bin/cmake/linux/share/cmake-3.19/Modules/FindBoost.cmake:460 (find_package)
CMakeLists.txt:7 (find_package)
-- Boost toolset is unknown (compiler )
-- Configuring incomplete, errors occurred!
My CMake file looks like following
cmake_minimum_required(VERSION 3.16)
project(chaotic_attractor CUDA)
set(CMAKE_CUDA_STANDARD 14)
find_package(Boost 1.71.0 REQUIRED COMPONENTS program_options)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(chaotic_attractor strangeattractor/main.cu)
target_link_libraries(chaotic_attractor ${Boost_LIBRARIES})
set_target_properties(
chaotic_attractor
PROPERTIES
CUDA_SEPARABLE_COMPILATION ON)
It is not clear to me if NVCC and Boost can get along. Does anyone have an idea how to solve this problem?
Enabling the CXX language here is apparently a requirement for Boost.
cmake_minimum_required(VERSION 3.16)
project(chaotic_attractor LANGUAGES CXX CUDA)
set(CMAKE_CUDA_STANDARD 14)
...
This is in my CMakeLists.txt:
cmake_minimum_required(VERSION 3.1.0)
project(myProject)
set(EXECUTABLE_OUTPUT_PATH ./bin/${CMAKE_BUILD_TYPE})
find_package(Boost REQUIRED COMPONENTS filesystem)
I compiled Boost 1.64.0 from source. The Boost compilation succeeded, and the filesystem headers are present in the Boost installation directory. I then pointed Boost_INCLUDE_DIR to its base folder (the one containing bootstrap and b2.exe).
I get this CMake output:
CMake Error at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find Boost (missing: filesystem) (found version "1.64.0")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.18/Modules/FindBoost.cmake:2177 (find_package_handle_standard_args)
CMakeLists.txt:9 (find_package)
Configuring incomplete, errors occurred!
What does this mean? How can CMake "NOT find Boost", but find version 1.64.0?
I downloaded the mpich-3.3.2 archive (stable release) from the official site, unpacked it and concluded that I have the MPICH library. But I can’t add it to Clion. Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
project(MyProject)
set(CMAKE_CXX_STANDARD 17)
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
add_executable(MyProject main.cpp)
I tried to enter different things in CMakeLists.txt, but always the same thing:
-- Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS)
-- Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS)
CMake Error at C:/Program Files/JetBrains/CLion 2019.3.4/bin/cmake/win/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND)
Call Stack (most recent call first):
C:/Program Files/JetBrains/CLion 2019.3.4/bin/cmake/win/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/JetBrains/CLion 2019.3.4/bin/cmake/win/share/cmake-3.16/Modules/FindMPI.cmake:1700 (find_package_handle_standard_args)
CMakeLists.txt:6 (find_package)
What am I doing wrong? How should Clion find out the location of MPICH on my computer?
I have cygwin in c:\cygwin64 and boost_1_64_0 in /usr/src file. Here is my CMakeLists.txt:
set(BOOST_HOME /usr/src/boost_1_64_0)
set(BOOST_INCLUDEDIR /usr/src/boost_1_64_0/boost)
cmake_minimum_required(VERSION 3.8)
project(spider)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
set(THREADS_PREFER_PTHREAD_FLAG ON)
include_directories(boost ${BOOST_HOME})
find_package(Threads REQUIRED)
find_package(Boost 1.64.0 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(spider ${SOURCE_FILES})
target_link_libraries(spider ${Boost_LIBRARIES})
target_link_libraries(spider Threads::Threads)
Clion starts cmake this way:
C:\Users\steve\.CLion2017.2\system\cygwin_cmake\bin\cmake.exe --build C:\Users\steve\Dropbox\Projects\cpp-spider\cmake-build-debug --target spider -- -j 1
I get this error:
CMake Warning at /cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:765 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
/cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:869 (_Boost_COMPONENT_DEPENDENCIES)
/cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:1472 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:17 (find_package)
CMake Warning at /cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:765 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
/cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:869 (_Boost_COMPONENT_DEPENDENCIES)
/cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:1472 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:17 (find_package)
CMake Error at /cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:1842 (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:17 (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)
used as include directory in directory /cygdrive/c/Users/steve/Dropbox/Projects/cpp-spider
used as include directory in directory /cygdrive/c/Users/steve/Dropbox/Projects/cpp-spider
used as include directory in directory /cygdrive/c/Users/steve/Dropbox/Projects/cpp-spider
-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/steve/Dropbox/Projects/cpp-spider/cmake-build-debug/CMakeFiles/CMakeOutput.log".
make: *** [Makefile:176: cmake_check_build_system] Error 1
How can I diagnose the reason of the problem? Any idea how I can fix it?
I have written a c++ program and run it in linux ubuntu. my program's name is: "find_relation_1.cpp" and this is its cmakelist.txt:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(find_relation_1)
find_package(PCL 1.2 REQUIRED)
find_package(Qt4 REQUIRED)
find_package(Qt COMPONENTS QtXml REQUIRED)
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
include_directories(${PCL_INCLUDE_DIRS} ${QT_INCLUDE_DIRS} ${QT_USE_FILE})
link_directories(${PCL_LIBRARY_DIRS} ${QT_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS} ${QT_DEFINITIONS})
add_executable (find_relation_1 find_relation_1.cpp)
target_link_libraries (find_relation_1 ${PCL_LIBRARIES})
target_link_libraries (find_relation_1 opencv_core opencv_imgproc opencv_video ${EXTERNAL_LIBS} ${QT_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_LIBRARIES} ${QT_QTXML_LIBRARY})
I had no problems and my program was running successfully after "cmake .." and "make".
Then I changed the name of the folder which my program:"find_relation_1.cpp" and its cmakelist: "CmakeList.txt" were in that. This time after writing cmake .. in the Terminal I received this error:
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
Could NOT find Qt4 (missing: QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE
QT_UIC_EXECUTABLE) (found version "4.8.6")
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-2.8/Modules/FindQt4.cmake:1171 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:7 (find_package)
-- Configuring incomplete, errors occurred!
Then I changed the name of the folder to its previous name while I had no problem but still this message is appeared after writing "cmake .." when I want to run my program. What is the reason for this error?