-1

I want to install RTABMap with vcpkg and then use VSCode as editor to include RTABMap into my C++ project. I installed RTABMap as described on their wiki with vcpkg install rtabmap:x64-windows (i also tried the x86 triplet) and then wanted to use it in my project. To get started I wrote the following cmake file based on an example from their repository:

cmake_minimum_required(VERSION 3.5)
project(RTABMap_Test VERSION 0.1.0)
 
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
find_package(RTABMap REQUIRED)
find_package(OpenCV REQUIRED)

set(INCLUDE_DIRS
    ${RTABMap_INCLUDE_DIRS}
    ${OpenCV_INCLUDE_DIRS}
)
set(LIBRARIES
    ${RTABMap_LIBRARIES}
    ${OpenCV_LIBRARIES} 
)

include_directories(${INCLUDE_DIRS})
add_executable(RTABMap_Test main.cpp)
target_link_libraries(RTABMap_Test ${LIBRARIES})

and the following main.cpp file:

#include <rtabmap/core/Rtabmap.h>

int main(void) {
  return 0;
}

The cmake settings in VSCode are as follows:

 "cmake.configureSettings": {
    "CMAKE_TOOLCHAIN_FILE": "G:/.vcpkg/scripts/buildsystems/vcpkg.cmake",
    "VCPKG_TARGET_TRIPLET": "x64-windows"
  }

However, when I run CMake: Build from VSCode, cmake fails with the following message:

-- Building for: Visual Studio 17 2022 -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044. -- The C compiler identification is MSVC 19.32.31332.0 -- The CXX compiler identification is MSVC 19.32.31332.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Warning at G:/.vcpkg/installed/x64-windows/share/rtabmap/RTABMapConfig.cmake:78 (MESSAGE): Asked for "gui" module but RTABMap hasn't been built with gui support. Call Stack (most recent call first): G:/.vcpkg/scripts/buildsystems/vcpkg.cmake:843 (_find_package) CMakeLists.txt:6 (find_package)

-- Found RTABMap: RTABMap_CORE_RELEASE-NOTFOUND;RTABMap_UTILITE_RELEASE-NOTFOUND;optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib
-- Found Protobuf: G:/.vcpkg/installed/x64-windows/tools/protobuf/protoc.exe (found version "3.21.12.0") -- Looking for pthread.h -- Looking for pthread.h - not found -- Found Threads: TRUE
-- Found TIFF: optimized;G:/.vcpkg/installed/x64-windows/lib/tiff.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/tiffd.lib (found version "4.5.0")
-- Found HDF5: hdf5::hdf5-shared (found version "1.12.2")
-- Found ZLIB: optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib (found suitable version "1.2.13", minimum required is "1") -- Found JPEG: optimized;G:/.vcpkg/installed/x64-windows/lib/jpeg.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/jpeg.lib (found version "62") -- Found ZLIB: optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib (found version "1.2.13") -- Found PNG: optimized;G:/.vcpkg/installed/x64-windows/lib/libpng16.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/libpng16d.lib (found version "1.6.39") -- Found GIF: optimized;G:/.vcpkg/installed/x64-windows/lib/gif.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/gif.lib (found version "5.2.1") -- Found LibArchive: G:/.vcpkg/installed/x64-windows/debug/lib/archive.lib (found version "3.6.2") -- Found OpenCV: G:/.vcpkg/installed/x64-windows (found version "4.7.0") -- Configuring done 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: RTABMap_CORE_RELEASE linked by target "RTABMap_Test" in directory G:/FKIE/rtabmap_test RTABMap_UTILITE_RELEASE linked by target "RTABMap_Test" in directory G:/FKIE/rtabmap_test

-- Generating done CMake Generate step failed. Build files cannot be regenerated correctly.

On the other hand, when I run cmake . -DCMAKE_TOOLCHAIN_FILE=G:/.vcpkg/scripts/buildsystems/vcpkg.cmake I get this error:

-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044. CMake Warning at G:/.vcpkg/installed/x64-windows/share/rtabmap/RTABMapConfig.cmake:78 (MESSAGE): Asked for "gui" module but RTABMap hasn't been built with gui support. Call Stack (most recent call first): G:/.vcpkg/scripts/buildsystems/vcpkg.cmake:843 (_find_package) CMakeLists.txt:6 (find_package)

-- Found ZLIB: optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib (found suitable version "1.2.13", minimum required is "1") -- Found ZLIB: optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib (found version "1.2.13") -- Configuring done 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: RTABMap_CORE_RELEASE linked by target "RTABMap_Test" in directory G:/FKIE/rtabmap_test RTABMap_UTILITE_RELEASE linked by target "RTABMap_Test" in directory G:/FKIE/rtabmap_test

-- Generating done CMake Generate step failed. Build files cannot be regenerated correctly.

The two missing variables are set in the RTABMapConfig.cmake.in located at the root directory of the RTABMap repository and used by the CMakeLists.txt, so I assume that I don't have to set them manually, meaning -- as far as I can tell -- when vcpkg installs RTABMap it doesn't properly configure RTABMap.

What to do?

Ruhrpottpatriot
  • 1,058
  • 3
  • 17
  • 31
  • ***The two missing variables are set in the RTABMapConfig.cmake.in located at the root directory of the RTABMap repository and used by the CMakeLists.txt, so I assume that I don't have to set them manually*** No when you configure and generate the project the `RTABMapConfig.cmake.in` file should generate a `RTABMapConfig.cmake` file in the build folder using [https://cmake.org/cmake/help/latest/command/configure_file.html](https://cmake.org/cmake/help/latest/command/configure_file.html) – drescherjm Feb 01 '23 at 15:30
  • But that's exactly what happens in the CMakeLists.txt from RTABMap. So I don't exactly follow you. – Ruhrpottpatriot Feb 01 '23 at 15:43
  • You said that you found the two missing variables in the `RTABMapConfig.cmake.in` when CMake generated the `RTABMap` project it should have filled the variables in the `RTABMapConfig.cmake` file that was generated. And when you use find_package() in your CMakeLists.txt these should be used when find_package reads this file. Is there a `RTABMapConfig.cmake` file? – drescherjm Feb 01 '23 at 15:56
  • The authors of that project don't know how to write a proper `.cmake.in` file that generates the final `ProjectConfig.cmake` file, see my "answer" (more of a hint) for more details. Note that `.cmake.in` is only used for the creation of the final `Config.cmake` file. – Milan Š. Feb 01 '23 at 16:56

1 Answers1

0

I had to write this as an answer due to character limitation. It's however more of a hint on what to look at rather then how to fix it.

Let's take a look at how RTABMapConfig.cmake is generated via the precursor file RTABMapConfig.cmake.in:

Lines 18-21:

find_library(RTABMap_CORE_RELEASE NAMES rtabmap_core NO_DEFAULT_PATH HINTS @CONF_LIB_DIR@)
find_library(RTABMap_CORE_DEBUG NAMES rtabmap_cored NO_DEFAULT_PATH HINTS @CONF_LIB_DIR@)

IF(RTABMap_CORE_DEBUG AND RTABMap_CORE_RELEASE)
#...

Not ideal for a .cmake.in but I'm not going to judge that. All that I'm going to say is that parts of the code rely on certain variables being set. The same variables that were "NOT FOUND" in your generation i.e. this line in the generation step:

-- [...] RTABMap_CORE_RELEASE-NOTFOUND [...]

If you would traverse the .cmake.in file down you would notice the same for the other "NOT FOUND" variable.

Later on we have:

Line 47:

set(RTABMap_LIBRARIES ${RTABMap_CORE} ${RTABMap_UTILITE})

Which is (as you probably know by now) empty.

Conclusion and possible solutions:


The RTABMapConfig.cmake can't find the proper libraries (if they exist) this can be caused either by the fact that during the vcpkg install phase something went wrong and the libraries weren't built OR the RTABMapConfig.cmake was poorly generated and needs to be fixed (the paths to the core and utilite libraries specifically)

  1. Check if something like rtabmap_core.lib exists and if not - compilation failed and you need to reinstall rtabmap
  2. If ad1) isn't the case then open up the RTABMapConfig.cmake and look at the paths to these libraries - fix them if needed.

EDIT: If I were you I would open up an issue on vcpkg's github.

Milan Š.
  • 1,353
  • 1
  • 2
  • 11