【问题标题】:How to compile RealSense examples?如何编译实感示例?
【发布时间】:2020-11-14 13:25:46
【问题描述】:

我已经从他们的Github page 克隆了 RealSense 官方源代码。编译示例 align-advanced 时出现问题。以下是我的终端情况:

$ cd ~/librealsense/examples/align-advanced
$ mkdir build
$ cd build
~/librealsense/examples/align-advanced/build$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/automation/librealsense/examples/align-advanced/build
~/librealsense/examples/align-advanced/build$ make
~/librealsense/examples/align-advanced/build$

如您所见,输入make 后没有任何反应,build 文件夹中也没有出现可执行文件。 官方CMakeList.txt内容如下:

# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2019 Intel Corporation. All Rights Reserved.
#  minimum required cmake version: 3.1.0
cmake_minimum_required(VERSION 3.1.0)

project(RealsenseExamplesAlignAdvanced)

if(BUILD_GRAPHICAL_EXAMPLES)
    add_executable(rs-align-advanced rs-align-advanced.cpp ../../third-party/imgui/imgui.cpp ../../third-party/imgui/imgui_draw.cpp ../../third-party/imgui/imgui_impl_glfw.cpp)
    set_property(TARGET rs-align-advanced PROPERTY CXX_STANDARD 11)
    target_link_libraries(rs-align-advanced ${DEPENDENCIES})
    include_directories(rs-align-advanced ../../common ../../third-party/imgui)
    set_target_properties (rs-align-advanced PROPERTIES FOLDER Examples)
    install(TARGETS rs-align-advanced RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

有什么问题?

【问题讨论】:

    标签: c++ ubuntu cmake realsense


    【解决方案1】:

    CMake 旨在从整个项目的 顶级 目录运行。这是一般的 CMake 经验法则;它通常适用于任何基于 CMake 的项目,而不仅仅是 RealSense。

    如果您想启用 RealSense 示例的编译,您可以通过 CMake 使用 BUILD_EXAMPLES 变量对其进行控制,如 Build Configuration 文档所示。但是,这仅构建了示例的一小部分。要构建align-advanced 示例,您还需要设置BUILD_GRAPHICAL_EXAMPLES

    cd ~/librealsense
    mkdir build; cd build
    cmake -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=true ..
    make
    

    【讨论】:

    • 您好 squareskittles,感谢您的回答!我按照您的指示进行了操作。但是输入make后,终端仍然没有提示,build文件夹中也没有出现可执行文件。题中添加了程序的官方CMakeLists.txt文件。
    • @simon00715 您还需要设置BUILD_GRAPHICAL_EXAMPLES 变量来构建align-advanced 示例。没有它,只能构建几个示例。我鼓励您查看链接的 RealSense 构建配置页面,以查看您可以设置以影响构建的所有 CMake 变量。此外,请务必删除您在以前的配置中使用的 CMake 构建文件夹,以确保旧的缓存数据不会仍然影响您的新构建尝试。
    猜你喜欢
    • 2012-03-12
    • 1970-01-01
    • 2013-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-19
    • 2011-12-29
    • 1970-01-01
    相关资源
    最近更新 更多