My goal is to install a library (rbdl-orb) on my Mac and import the library in a C++ program.
My first attempt was to clone the library and run the included example directly. The program "example.cc" starts with the following two lines:
#include <iostream>
#include <rbdl/rbdl.h>
The CMake file follows:
PROJECT (RBDLEXAMPLE CXX)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
# We need to add the project source path to the CMake module path so that
# the FindRBDL.cmake script can be found.
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} )
SET(CUSTOM_RBDL_PATH "" CACHE PATH "Path to specific RBDL Installation")
# Search for the RBDL include directory and library
FIND_PACKAGE (RBDL REQUIRED)
FIND_PACKAGE (Eigen3 3.0.0 REQUIRED)
# Add the include directory to the include paths
INCLUDE_DIRECTORIES ( ${RBDL_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR} )
# Create an executable
ADD_EXECUTABLE (example example.cc)
# And link the library against the executable
TARGET_LINK_LIBRARIES (example
${RBDL_LIBRARY}
)
Typing "make example" yields the following error:
c++ example.cc -o example
example.cc:10:10: fatal error: 'rbdl/rbdl.h' file not found
#include <rbdl/rbdl.h>
^~~~~~~~~~~~~
1 error generated.
make: *** [example] Error 1
I am guessing that there are steps needed to install the library, such that the C++ compiler knows where to look for the files when it sees the command "import". The library's GitHub notes that the package is available for installation through vcpkg.
I installed vcpkg by following the instructions. Then, I built the library by typing "vcpkg install rbdl" in a Terminal. Typing "vcpkg list" in the working directory shows that the library appears to be installed:
(base) my_name@my_name-MacBook-Pro current_directory % vcpkg list
eigen3:arm64-osx 3.4.0#2 C++ template library for linear algebra: matrice...
rbdl:arm64-osx 2.6.0#2 Rigid Body Dynamics Library
vcpkg-cmake-config:arm64-osx 2022-02-06
vcpkg-cmake:arm64-osx 2022-04-07
Unfortunately, typing "make example" again yields the following error:
c++ example.cc -o example
example.cc:10:10: fatal error: 'rbdl/rbdl.h' file not found
#include <rbdl/rbdl.h>
^~~~~~~~~~~~~
1 error generated.
make: *** [example] Error 1
The error suggests that the C++ compiler is not aware of the location where the library was installed.
How can I correctly install the library and import it in my C++ program?