PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
10k stars 4.62k forks source link

[Compile Error] Could NOT find Boost: Missing Components when Integrating PCL 1.14.1 with CMake on Windows 11 #6142

Closed vinarro closed 1 month ago

vinarro commented 1 month ago

Describe the error

When using Visual Studio 2019 x64 compiler and CMake build system on Windows 11 23H2, integrating PCL version 1.14.1, I encountered the following error:

[main] 正在配置项目: pclTest 
[proc] 执行命令: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -SD:/workspace/c++/pclTest -Bd:/workspace/c++/pclTest/build -G "Visual Studio 16 2019" -T host=x64 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22631.
[cmake] -- The CXX compiler identification is MSVC 19.29.30154.0
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] CMake Warning (dev) at D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:121 (find_package):
[cmake]   Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT
[cmake]   variables.  Run "cmake --help-policy CMP0144" for policy details.  Use the
[cmake]   cmake_policy command to set the policy and suppress this warning.
[cmake] 
[cmake]   CMake variable BOOST_ROOT is set to:
[cmake] 
[cmake]     D:/libraries/PCL_1.14.1/3rdParty/Boost
[cmake] 
[cmake]   For compatibility, find_package is ignoring the variable, but code in a
[cmake]   .cmake module might still use it.
[cmake] Call Stack (most recent call first):
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:294 (find_boost)
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:559 (find_external_library)
[cmake]   CMakeLists.txt:11 (find_package)
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.
[cmake] 
[cmake] CMake Warning (dev) at D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:121 (find_package):
[cmake]   Policy CMP0167 is not set: The FindBoost module is removed.  Run "cmake
[cmake]   --help-policy CMP0167" for policy details.  Use the cmake_policy command to
[cmake]   set the policy and suppress this warning.
[cmake] 
[cmake] Call Stack (most recent call first):
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:294 (find_boost)
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:559 (find_external_library)
[cmake]   CMakeLists.txt:11 (find_package)
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.
[cmake] 
[cmake] -- Could NOT find Boost: missing: system iostreams filesystem serialization (found D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/Boost-1.84.0/BoostConfig.cmake (found suitable version "1.84.0", minimum required is "1.65.0"))
[cmake] CMake Error at D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:59 (message):
[cmake]   common is required but boost was not found
[cmake] Call Stack (most recent call first):
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:370 (pcl_report_not_found)
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:559 (find_external_library)
[cmake]   CMakeLists.txt:11 (find_package)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[proc] 命令“"C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -SD:/workspace/c++/pclTest -Bd:/workspace/c++/pclTest/build -G "Visual Studio 16 2019" -T host=x64 -A x64”已退出,代码为 1

To Reproduce

  1. Use the following CMakeLists.txt configuration:
cmake_minimum_required(VERSION 3.21.0)
project(pclTest VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install)

set(PCL_DIR "D:/libraries/PCL_1.14.1/cmake")
find_package(PCL 1.14.1 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable(pclTest main.cpp)

target_link_libraries(pclTest ${PCL_LIBRARIES})
  1. Run CMake with the following command:
    "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -SD:/workspace/c++/pclTest -Bd:/workspace/c++/pclTest/build -G "Visual Studio 16 2019" -T host=x64 -A x64
  2. The error message mentioned above is displayed.

Screenshots/Code snippets/Build information

Your Environment (please complete the following information):

Possible Solution

N/A

Additional context

mvieth commented 1 month ago

@vinarro Can you set the CMake variable Boost_DEBUG to see more debug output?

vinarro commented 1 month ago

@mvieth Thank you for your suggestion. I have enabled Boost_DEBUG and here is the relevant output:

[main] 正在配置项目: pclTest 
[proc] 执行命令: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -SD:/workspace/c++/pclTest -Bd:/workspace/c++/pclTest/build -G "Visual Studio 16 2019" -T host=x64 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22631.
[cmake] -- The CXX compiler identification is MSVC 19.29.30154.0
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] CMake Warning (dev) at D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:121 (find_package):
[cmake]   Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT
[cmake]   variables.  Run "cmake --help-policy CMP0144" for policy details.  Use the
[cmake]   cmake_policy command to set the policy and suppress this warning.
[cmake] 
[cmake]   CMake variable BOOST_ROOT is set to:
[cmake] 
[cmake]     D:/libraries/PCL_1.14.1/3rdParty/Boost
[cmake] 
[cmake]   For compatibility, find_package is ignoring the variable, but code in a
[cmake]   .cmake module might still use it.
[cmake] Call Stack (most recent call first):
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:294 (find_boost)
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:559 (find_external_library)
[cmake]   CMakeLists.txt:12 (find_package)
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.
[cmake] 
[cmake] CMake Warning (dev) at D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:121 (find_package):
[cmake]   Policy CMP0167 is not set: The FindBoost module is removed.  Run "cmake
[cmake]   --help-policy CMP0167" for policy details.  Use the cmake_policy command to
[cmake]   set the policy and suppress this warning.
[cmake] 
[cmake] Call Stack (most recent call first):
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:294 (find_boost)
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:559 (find_external_library)
[cmake]   CMakeLists.txt:12 (find_package)
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.
[cmake] 
[cmake] -- Found Boost 1.84.0 at D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/Boost-1.84.0
[cmake] --   Requested configuration: QUIET COMPONENTS system;iostreams;filesystem;serialization
[cmake] -- BoostConfig: find_package(boost_headers 1.84.0 EXACT CONFIG  QUIET HINTS D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake)
[cmake] -- Found boost_headers 1.84.0 at D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_headers-1.84.0
[cmake] -- BoostConfig: find_package(boost_system 1.84.0 EXACT CONFIG  QUIET HINTS D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake)
[cmake] -- Found boost_system 1.84.0 at D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_system-1.84.0
[cmake] -- Boost toolset is vc142 (MSVC 19.29.30154.0)
[cmake] -- Scanning D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_system-1.84.0/libboost_system-variant*.cmake
[cmake] --   Including D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_system-1.84.0/libboost_system-variant-vc143-mt-gd-x64-1_84-static.cmake
[cmake] --   [ ] libboost_system-vc143-mt-gd-x64-1_84.lib
[cmake] --   Including D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_system-1.84.0/libboost_system-variant-vc143-mt-x64-1_84-static.cmake
[cmake] --   [ ] libboost_system-vc143-mt-x64-1_84.lib
[cmake] -- BoostConfig: find_package(boost_iostreams 1.84.0 EXACT CONFIG  QUIET HINTS D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake)
[cmake] -- Found boost_iostreams 1.84.0 at D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_iostreams-1.84.0
[cmake] -- Boost toolset is vc142 (MSVC 19.29.30154.0)
[cmake] -- Scanning D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_iostreams-1.84.0/libboost_iostreams-variant*.cmake
[cmake] --   Including D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_iostreams-1.84.0/libboost_iostreams-variant-vc143-mt-gd-x64-1_84-static.cmake
[cmake] --   [ ] libboost_iostreams-vc143-mt-gd-x64-1_84.lib
[cmake] --   Including D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_iostreams-1.84.0/libboost_iostreams-variant-vc143-mt-x64-1_84-static.cmake
[cmake] --   [ ] libboost_iostreams-vc143-mt-x64-1_84.lib
[cmake] -- BoostConfig: find_package(boost_filesystem 1.84.0 EXACT CONFIG  QUIET HINTS D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake)
[cmake] -- Found boost_filesystem 1.84.0 at D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_filesystem-1.84.0
[cmake] -- Boost toolset is vc142 (MSVC 19.29.30154.0)
[cmake] -- Scanning D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_filesystem-1.84.0/libboost_filesystem-variant*.cmake
[cmake] --   Including D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_filesystem-1.84.0/libboost_filesystem-variant-vc143-mt-gd-x64-1_84-static.cmake
[cmake] --   [ ] libboost_filesystem-vc143-mt-gd-x64-1_84.lib
[cmake] --   Including D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_filesystem-1.84.0/libboost_filesystem-variant-vc143-mt-x64-1_84-static.cmake
[cmake] --   [ ] libboost_filesystem-vc143-mt-x64-1_84.lib
[cmake] -- BoostConfig: find_package(boost_serialization 1.84.0 EXACT CONFIG  QUIET HINTS D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake)
[cmake] -- Found boost_serialization 1.84.0 at D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_serialization-1.84.0
[cmake] -- Boost toolset is vc142 (MSVC 19.29.30154.0)
[cmake] -- Scanning D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_serialization-1.84.0/libboost_serialization-variant*.cmake
[cmake] --   Including D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_serialization-1.84.0/libboost_serialization-variant-vc143-mt-gd-x64-1_84-static.cmake
[cmake] --   [ ] libboost_serialization-vc143-mt-gd-x64-1_84.lib
[cmake] --   Including D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/boost_serialization-1.84.0/libboost_serialization-variant-vc143-mt-x64-1_84-static.cmake
[cmake] --   [ ] libboost_serialization-vc143-mt-x64-1_84.lib
[cmake] -- Could NOT find Boost: missing: system iostreams filesystem serialization (found D:/libraries/PCL_1.14.1/3rdParty/Boost/lib/cmake/Boost-1.84.0/BoostConfig.cmake (found suitable version "1.84.0", minimum required is "1.65.0"))
[cmake] CMake Error at D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:59 (message):
[cmake]   common is required but boost was not found
[cmake] Call Stack (most recent call first):
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:370 (pcl_report_not_found)
[cmake]   D:/libraries/PCL_1.14.1/cmake/PCLConfig.cmake:559 (find_external_library)
[cmake]   CMakeLists.txt:12 (find_package)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[proc] 命令“"C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -SD:/workspace/c++/pclTest -Bd:/workspace/c++/pclTest/build -G "Visual Studio 16 2019" -T host=x64 -A x64”已退出,代码为 1

It seems that CMake successfully locates the BoostConfig.cmake file, but it cannot find the specific Boost components: system, iostreams, filesystem, and serialization.

Would you have any suggestions on how to proceed from here? Should I manually specify the paths for these missing components, or is there something else I should check in the configuration?

Thank you again for your help.

mvieth commented 1 month ago

@vinarro I believe the reason is that the AllInOne installer you used was built with MSVC 2022 (including the Boost installation), but you are using MSVC 2019. In the logs you see Boost toolset is vc142, but the boost libraries all have vc143 in their name. I see the following options:

vinarro commented 1 month ago

@mvieth Thank you very much for the quick and helpful response! After switching to MSVC 2022, the issue was resolved, and I was able to successfully build my project.

I also wanted to suggest that it might be helpful to add a check in the CMake configuration file to ensure compatibility between the MSVC version and the libraries (such as Boost) included in the AllInOne installer. A warning or an error message that checks for the correct compiler version could help prevent this issue in the future.

Thanks again for your support, and I appreciate all the work that goes into maintaining PCL!