【发布时间】:2020-04-06 15:21:44
【问题描述】:
我从源安装了librealsense。它已安装并成功构建。
当我尝试运行示例项目 (rs-hello-realsense) 时,我发现了构建错误。
/usr/local/include/librealsense2/hpp/rs_types.hpp:90: undefined reference to `rs2_get_error_message'
/usr/local/include/librealsense2/hpp/rs_types.hpp:92: undefined reference to `rs2_get_failed_function'
/usr/local/include/librealsense2/hpp/rs_types.hpp:92: undefined reference to `rs2_get_failed_function'
来自不同类型的构建的相同类型的错误。
CMakeFiles/rs-hello-realsense.dir/rs-hello-realsense.cpp.o: In function `rs2::error::error(rs2_error*)':
rs-hello-realsense.cpp:(.text._ZN3rs25errorC2EP9rs2_error[_ZN3rs25errorC5EP9rs2_error]+0x2e): undefined reference to `rs2_get_error_message'
rs-hello-realsense.cpp:(.text._ZN3rs25errorC2EP9rs2_error[_ZN3rs25errorC5EP9rs2_error]+0x73): undefined reference to `rs2_get_failed_function'
【问题讨论】:
-
你链接图书馆了吗?
-
我需要在哪里链接库?当它构建时,它已经构建在 /use/local/ 中,我可以通过 include '#include
' 来使用它,不是吗? -
构建过程包含编译步骤和链接器步骤。在编译步骤中,头文件被添加到编译单元。在链接器步骤中,库被链接到您的工件中。您需要像
-lLIBRARY这样的链接器标志,可能像-lrealsense2这样的东西。 gcc.gnu.org/onlinedocs/gcc/Link-Options.html