I am trying to build Point Cloud Library on Windows.
https://github.com/PointCloudLibrary/pcl
This library requires Boost library and I have installed it properly.
However, when I use CMAKE to build PCL, it complains that
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.3/Modules/FindBoost.cmake:1245 (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):
cmake/pcl_find_boost.cmake:37 (find_package)
CMakeLists.txt:399 (include)
I have BOOST_ROOT set in my environment variables:
Furthermore, CMAKE doesn't even show the BOOST_ROOT or BOOST_INCLUDEDIR variables in its variable name list:
Below is the pcl_find_boost.cmake file
# Find and set Boost flags
# If we would like to compile against a dynamically linked Boost
if(PCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32 AND WIN32)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC OFF)
set(Boost_USE_MULTITHREAD ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB")
else(PCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32 AND WIN32)
if(NOT PCL_SHARED_LIBS OR WIN32)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC ON)
endif(NOT PCL_SHARED_LIBS OR WIN32)
endif(PCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32 AND WIN32)
if(${CMAKE_VERSION} VERSION_LESS 2.8.5)
SET(Boost_ADDITIONAL_VERSIONS "1.43" "1.43.0" "1.44" "1.44.0" "1.45" "1.45.0" "1.46.1" "1.46.0" "1.46" "1.47" "1.47.0")
else(${CMAKE_VERSION} VERSION_LESS 2.8.5)
SET(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0" "1.48" "1.48.0" "1.49" "1.49.0")
endif(${CMAKE_VERSION} VERSION_LESS 2.8.5)
# Disable the config mode of find_package(Boost)
set(Boost_NO_BOOST_CMAKE ON)
# Optional boost modules
find_package(Boost 1.40.0 QUIET COMPONENTS serialization mpi)
if(Boost_SERIALIZATION_FOUND)
set(BOOST_SERIALIZATION_FOUND TRUE)
endif(Boost_SERIALIZATION_FOUND)
# Required boost modules
if(WITH_OPENNI2)
set(BOOST_REQUIRED_MODULES system filesystem thread date_time iostreams chrono)
find_package(Boost 1.47.0 REQUIRED COMPONENTS ${BOOST_REQUIRED_MODULES})
else()
set(BOOST_REQUIRED_MODULES system filesystem thread date_time iostreams)
find_package(Boost 1.40.0 REQUIRED COMPONENTS ${BOOST_REQUIRED_MODULES})
endif()
if(Boost_FOUND)
set(BOOST_FOUND TRUE)
# Obtain diagnostic information about Boost's automatic linking outputted
# during compilation time.
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
endif(Boost_FOUND)
Thanks in advance for the help!
Related
I'm using Boost 1.79 and Windows 10. For building Boost libs I use TDM MinGW. After trying to build my test program with CMake, I get next error:
CMake Error at D:/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Boost (missing: log thread) (found suitable version
"1.79.0", minimum required is "1.79")
Call Stack (most recent call first):
D:/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
D:/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
CMakeLists.txt:16 (find_package)
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.24)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_C_COMPILER "D:/TDM-MinGW/bin/gcc.exe")
#set(CMAKE_CXX_COMPILER "D:/TDM-MinGW/bin/g++.exe")
set(Boost_DEBUG=ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
project (testlib)
find_package(Boost 1.79 COMPONENTS log thread REQUIRED)
IF(Boost_FOUND)
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR})
LINK_DIRECTORIES(${Boost_LIBRARY_DIR})
MESSAGE("Boost information")
MESSAGE("Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
MESSAGE("Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
MESSAGE("Boost_Version: ${Boost_VERSION}")
MESSAGE("Boost Libraries: ${Boost_LIBRARIES}")
ENDIF()
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
add_executable(testlib src/main.cpp)
target_link_libraries(testlib PUBLIC ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
Boost libs were compiled by following command:
./b2 --build-type=complete -j 8 variant=debug address-model=64 link=static toolset=gcc install
Well, I solve my problem by setting Boost_DEBUG to ON. After analyzing debug info it became clear that the problem was two empty variables: Boost_COMPILER and Boost_ARCHITECTURE. And to solve the problem i just set these variables by looking at the full filename, for example:
We have filename libboost_log-clang14-mt-x32-1_79.lib, and we need this parts: -clang14 and -x32. You should look at this parts at your filename and set this parts as CMake variables:
Boost_ARCHITECTURE = -x32
Boost_COMPILER = -clang14
I want to build the following project: https://github.com/reo7sp/tgbot-cpp
I get these errors: https://imgur.com/S9kgWyv
Makefile part 1: https://imgur.com/O222bJR
Makefile part 2: https://imgur.com/i68QLdC
Now, I think that I need zlib, openssl and boost. Curl seems to be optional.
What is "threads"?
And what is the difference between ...LIBRARY_DEBUG and ...LIBRARY_RELEASE?
What doe LIB and SSL mean in the gui? These "libraries" are not mentioned in the makefile?
I am desperate for days now. Please, help me.
Error:
CMake Error at D:/Programme/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (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.0j")
Call Stack (most recent call first):
D:/Programme/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
D:/Programme/CMake/share/cmake-3.13/Modules/FindOpenSSL.cmake:412 (find_package_handle_standard_args)
CMakeLists.txt:47 (find_package)
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.4)
project(TgBot)
if (${CONAN_EXPORTED})
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
endif()
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# options
option(ENABLE_TESTS "Set to ON to enable building of tests" OFF)
option(BUILD_SHARED_LIBS "Build tgbot-cpp shared/static library." OFF)
# sources
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Do not activate all warnings in VS (too much output for Appveyor)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
endif()
include_directories(include)
set(SRC_LIST
src/Api.cpp
src/EventHandler.cpp
src/TgException.cpp
src/TgTypeParser.cpp
src/net/BoostHttpOnlySslClient.cpp
src/net/CurlHttpClient.cpp
src/net/HttpParser.cpp
src/net/TgLongPoll.cpp
src/net/Url.cpp
src/tools/FileTools.cpp
src/tools/StringTools.cpp
src/types/InlineQueryResult.cpp
src/types/InputFile.cpp
)
# libs
## threads
find_package(Threads REQUIRED)
# zlib
find_package(ZLIB REQUIRED)
## openssl
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
## curl
find_package(CURL)
if (CURL_FOUND)
include_directories(${CURL_INCLUDE_DIRS})
add_definitions(-DHAVE_CURL)
endif()
## boost
set(Boost_USE_MULTITHREADED ON)
if (ENABLE_TESTS)
find_package(Boost 1.59.0 COMPONENTS system unit_test_framework REQUIRED)
else()
find_package(Boost 1.59.0 COMPONENTS system REQUIRED)
endif()
include_directories(${Boost_INCLUDE_DIR})
set(LIB_LIST
${CMAKE_THREAD_LIBS_INIT}
${ZLIB_LIBRARIES}
${OPENSSL_LIBRARIES}
${Boost_LIBRARIES}
${CURL_LIBRARIES}
)
# building project
add_library(${PROJECT_NAME} ${SRC_LIST})
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_link_libraries(${PROJECT_NAME} ${LIB_LIST})
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)
# tests
if (ENABLE_TESTS)
message(STATUS "Building of tests is enabled")
enable_testing()
add_subdirectory(test)
endif()
It turned out that I needed to set some system variables for OpenSSL, ZLib, Boost, curl. For Zlib just do the same procedure. drescherjm was a huge help. So thanks!
Tutorial for this:
OpenSSL: https://www.youtube.com/watch?v=3I7eL2Mm6Ps&index=34&t=0s&list=PLcmZ3Jkh7taY1ensPUAJ4VfMEicDcihhg
and
curl: How do I install and use curl on Windows?
Setting up curl library path in cmake
I have been trying to run a Qt project in a CMake environment. The Qt project is using openCV and Boost dependencies. After successfully solving all compiling errors, I have been struggling with a Boost error.
As soon as I run CMake I get the following error:
Running "/usr/bin/cmake /home/labrat/Desktop/cam-proc '-GCodeBlocks - Unix Makefiles'" in /home/labrat/Desktop/cam-proc/build.
**CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message):**
Unable to find the requested Boost libraries.
Boost version: 1.58.0
Boost include path: /usr/include
Could not find the following Boost libraries:
boost_lboost_thread
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):
src/libCam/CMakeLists.txt:7 (find_package)**
Boost version: 1.58.0
Found the following Boost libraries:
system
thread
filesystem
chrono
date_time
atomic
-- Configuring incomplete, errors occurred!
See also "/home/labrat/Desktop/cam-proc/build/CMakeFiles/CMakeOutput.log".
See also "/home/labrat/Desktop/cam-proc/build/CMakeFiles/CMakeError.log".
*** cmake process exited with exit code 1.
I analyzed the error given CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message): and opened the enormous FindBoost.cmake file and here is the part where the error is, according to the warning, located:
message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
# Add pthread library on UNIX if thread component was found
_Boost_consider_adding_pthreads(Boost_LIBRARIES ${Boost_LIBRARIES})
else()
if(Boost_FIND_REQUIRED)
message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
else()
if(NOT Boost_FIND_QUIETLY)
# we opt not to automatically output Boost_ERROR_REASON here as
# it could be quite lengthy and somewhat imposing in its requests
# Since Boost is not always a required dependency we'll leave this
# up to the end-user.
if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
else()
message(STATUS "Could NOT find Boost")
endif()
endif()
endif()
endif()
Also since another part of the error message said Call Stack (most recent call first): src/libCam/CMakeLists.txt:7 (find_package) here I am attaching the CMakeLists.txt realted to the libcam project if that's helpful:
cmake_minimum_required (VERSION 2.8.12)
project(libCam)
find_package(Qt5Widgets REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Boost COMPONENTS filesystem lboost_thread system REQUIRED)
find_package(Boost COMPONENTS system thread filesystem REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
###
# make sure we use c++11
###
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS})
include_regular_expression("^([^b]|b[^o]|bo[^o]|boo[^s]|boos[^t]|boost[^/]).*$")
qt5_wrap_ui (UIS_HDRS qtinclude/imagemanager.ui qtinclude/stereomanager.ui qtinclude/stereolistwidget.ui qtinclude/connectionmenu.ui)
file(GLOB LIBCAM_SRCS
"include/*.h"
"include/*.cpp"
"include/*.hpp"
"qtinclude/*.h"
"qtinclude/*.cpp"
"qtinclude/*.hpp"
)
file(GLOB UI_RC
"qtinclude/qdarkstyle/*.qrc"
)
add_library(libCam SHARED ${LIBCAM_SRCS} ${UIS_HDRS} ${UI_RC})
target_include_directories (libCam PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} )
target_link_libraries (libCam Qt5::Widgets Qt5::PrintSupport Qt5::Core Qt5::Quick Qt5::Sql Qt5::XmlPatterns ${Boost_LIBRARIES} ${OpenCV_LIBS} )
I have been googling the error for the past two days looking for information and code to solve this problem, but I am running out of ideas. I tried to download boost 1.55 but it didn't work as the compiler only sees boost 1.58.
Any idea on how to shed light on this matter? Is there something I am leaving out?
The problem is the line
find_package(Boost COMPONENTS filesystem lboost_thread system REQUIRED)
which should be changed to
find_package(Boost COMPONENTS filesystem thread system REQUIRED)
or simply deleted, since it is then equivalent to the following line.
Using the following CMake code:
cmake_minimum_required(VERSION 3.6)
project(TrustLineManager)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(BOOST_ROOT D:/Tools/boost_1_62_0/)
set(Boost_INCLUDE_DIRS D:/Tools/boost_1_62_0/boost)
set(Boost_LIBRARY_DIRS D:/Tools/boost_1_62_0/libs)
set(BOOST_INCLUDEDIR C:/MinGW/include)
set(BOOST_LIBRARYDIR C:/MinGW/lib)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost
1.62.0
COMPONENTS system
filesystem
REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(TrustLineManager ${Boost_LIBRARIES})
I get this error:
Error:Unable to find the requested Boost libraries.
Boost version: 1.62.0
Boost include path: D:/Tools/boost_1_62_0
Could not find the following static 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.
What should I do to solve it?
EDIT:
I modified my CMake code into:
cmake_minimum_required(VERSION 3.6)
project(TrustLineManager)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
set(BOOST_ROOT "D:/Tools/boost_1_62_0")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(TrustLineManager ${SOURCE_FILES})
target_link_libraries(TrustLineManager Boost::filesystem Boost::thread)
I have now this error:
Error:Target "TrustLineManager" links to target "Boost::filesystem" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?
Here is a screenshot of Boost directory contents:
Obviously CMake finds Boost as it is able to detect its version (1.62.0).
CMake uses the file FindBoost.cmake to determine what libraries to link against.
This file is updated continuously when new boost versions appear.
There, support for Boost 1.62.0 is available only for CMake >= 3.7.0.
So just update your CMake version (or just the file FindBoost.cmake) and you will be fine.
the StackOverFlow community!
I'm trying to link up boost libraries and there's an error of linking up the 'boost_system' static library.
I use cmake 2.8, the MinGW compiler and the 1.55.0 boost.
Judging by the logs, cmake doesn't see the pathway to the libraries.
Here's the error:
Unable to find the requested Boost libraries.
Boost version: 1.55.0
Boost include path: c:/local/boost_1_55_0
Could not find the following static Boost libraries:
boost_system
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):
Here's the cmake code:
cmake_minimum_required(VERSION 2.8)
project(test)
if (WIN32)
set(BOOST_ROOT "c:/local/boost_1_55_0")
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib/)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.55 COMPONENTS system REQUIRED)
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
include_directories(${Boost_INCLUDE_DIR})
set(SOURCE_FILES main.cpp)
add_executable(test ${SOURCE_FILES})
target_link_libraries(test ${Boost_LIBRARIES})
endif (WIN32)
I receive logs like this with the declared set(Boost_DETAILED_FAILURE_MSG on)
status** Boost Include: c:/local/boost_1_55_0
status** Boost Libraries:
status** Boost Libraries:
For me worked setting hint variables CMAKE_INCLUDE_PATH & CMAKE_LIBRARY_PATH. BOOST_ROOT & BOOST_LIBRARYDIR were not working also.
Another hint variables are Boost_COMPILER, Boost_NAMESPACE, Boost_ARCHITECTURE they help to define how your library is named to boost search script.
Using SET(Boost_DEBUG 1) helped me a lot do diagnose a problem -as it prints Boost path suffixes= and _boost_LIBRARY_SEARCH_DIRS_RELEASE
For example
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "D:/boost/boost_1_70_0")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "D:/boost/boost_1_70_0/stage/gcc/x64/lib")
SET(Boost_COMPILER ${Boost_COMPILER} "-mgw73")
SET(Boost_NAMESPACE ${Boost_NAMESPACE} "libboost")
SET(Boost_ARCHITECTURE "-x64")
Or
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "D:/boost/boost_1_70_0")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "D:/boost/boost_1_70_0/stage/lib")
SET(Boost_COMPILER ${Boost_COMPILER} "-vc142")