slambook icon indicating copy to clipboard operation
slambook copied to clipboard

ch7/CMakeList.txt g2o相关

Open Jinxz666 opened this issue 6 years ago • 3 comments

By refering to #52 , the part of pose_estimation_3d2d & pose_estimation_3d3d should also be adjusted as following to avoid the error

while loading shared libraries: libg2o_core.so: cannot open shared object file: No such file or directory

target_link_libraries(…… ${G2O_CORE_LIBRARY} ${G2O_STUFF_LIBRARY} g2o_types_sba g2o_csparse_extension)

After modifying, I can execute the code successfully. While I still wondering whether should I operate to the last two g2o libraries and what is the difference between ${G2O_CORE_LIBRARY} and g2o_core in target_link libraries.

Jinxz666 avatar Jul 31 '18 03:07 Jinxz666

Take a look at FindG2O.cmake file which defines a macro to find g2o library and set their names. Almost all g2o_types_xxx are defined here. The FindG2O.cmake is in cmake_module directory of many projects that rely on g2o. For example here: https://github.com/gaoxiang12/slambook/blob/master/ch6/g2o_curve_fitting/cmake_modules/FindG2O.cmake

gaoxiang12 avatar Aug 01 '18 00:08 gaoxiang12

sudo gedit /etc/ld.so.conf

添加如下代码:

/usr/local/lib

运行:

sudo ldconfig

huangwen0907 avatar Aug 30 '19 08:08 huangwen0907

According to this answer, the following way also works:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

This is to temporarily add the path /usr/local/lib to the shared library search path. You can run this command before running g2o program.

It is also possible to add this line to the end of ~/.bashrc file, such that you don't need to run this command before running g2o program everytime.

hanzheteng avatar Mar 25 '20 00:03 hanzheteng