How to use locally installed gtsam in a third project?

413 views
Skip to first unread message

734657...@gmail.com

unread,
Oct 25, 2021, 10:46:16 PM10/25/21
to gtsam users

Hi all,
I build gtsam with default config except installing gtsam 4.1rc in my home path. In a ros package i config CMakeLists.txt as following:

set(CMAKE_PREFIX_PATH "/home/jxl/Documents/third_softwares/gtsam-4.1rc/INSTALL/lib/cmake/GTSAM/")
set(GTSAM_DIR "/home/jxl/Documents/third_softwares/gtsam-4.1rc/INSTALL/")

find_package(GTSAM REQUIRED QUIET)
include_directories(${GTSAM_INCLUDE_DIR})
link_directories(${GTSAM_LIBRARY_DIRS})
add_executable(executable_name source_cpp_files)
target_link_libraries(executable_name gtsam)

when catkin_make , output is:

/usr/bin/ld: cannot find -lgtsam

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/jxl/Documents/third_softwares/gtsam-4.1rc/INSTALL/lib/ and sudo ldconfig does not work, so how should i do to solve this problem?

Thanks for your help in advance

Jay Elrod

unread,
Oct 26, 2021, 12:55:51 PM10/26/21
to gtsam users
Pretty sure CMAKE_PREFIX_PATH should point the top-level install dir of your gtsam build rather than all the way down into the cmake files there, so changing that might help. You might want to also check that there is a symlink in that install dir that links to version-specific .so file like gtsam.so -> gtsam.so.4.1 for the linker to find.

734657...@gmail.com

unread,
Oct 27, 2021, 3:53:51 AM10/27/21
to gtsam users
Hi @Jay Elrod,  thanks for your help very much ! Set(CMAKE_PREFIX_PATH "/home/jxl/Documents/third_softwares/gtsam-4.1rc/INSTALL/") and without  export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/jxl/Documents/third_softwares/gtsam-4.1rc/INSTALL/lib  can work well, thanks again!   
Reply all
Reply to author
Forward
0 new messages