Ubuntu 18安装librealsense

  写在前面

    今天看到QQ“那年今日”提醒,三年前的今天我给自己写了一句话:等待机遇的同时不忘继续努力,走太远,别忘了为什么出发。

  对于记录个人生活而言,QQ比微信优秀太多了。可惜膨胀了,加了一大堆小众的功能,用户体验直线下降……额,扯远了。言归正传。

 

    因为项目是C++代码写的,之前装的Python版本的realsense库用不上了,只能build一个librealsense。

    由于前些天安装opencv安装怕了,怎么make怎么不行,所以听到partner说安装librealsense和opencv一样难搞时,我怯了。

    可事情总得去做,才有可能做成,对吧?

 

    安装之前,确保电脑没有接realsense设备。

    电脑系统:Ubuntu 18.04.4 LTS

    安装方法参考https://github.com/IntelRealSense/librealsense

    command:

git clone https://github.com/Microsoft/vcpkg.git

cd vcpkg

./bootstrap-vcpkg.sh

./vcpkg integrate install

./vcpkg install realsense2

    执行命令 ./bootstrap-vcpkg.sh 的时候会下载3个包:cmake、librealsense、ninja。

  下载过程比较慢,也许会失败,报错“过早的文件结束符(EOF)”之类的,此命令多执行几次,就可以下载好了。个中缘由,我归结为网络不好?

 

ljx@ljx-Lenovo:~/soft/vcpkg$ ./bootstrap-vcpkg.sh 
Extracting cmake...
Extracting cmake... done.
Downloading ninja...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   624  100   624    0     0    181      0  0:00:03  0:00:03 --:--:--   181
100 99857  100 99857    0     0   4844      0  0:00:20  0:00:20 --:--:-- 10906
Downloading ninja... done.
Extracting ninja...
Extracting ninja... done.
-- The CXX compiler identification is GNU 7.5.0
-- Check for working CXX compiler: /usr/bin/g++-7
-- Check for working CXX compiler: /usr/bin/g++-7 - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting the C++ compiler in use
-- Detecting the C++ compiler in use - gcc
-- Detecting the C++ standard library
-- Detecting the C++ standard library - libstdc++
-- Detecting how to use the C++ filesystem library
-- Detecting how to use the C++ filesystem library - <experimental/filesystem> with -l[std]c++fs
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ljx/soft/vcpkg/toolsrc/build.rel
[0/2] Re-checking globbed directories...
[79/79] Linking CXX executable vcpkg
Telemetry
---------
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.

Read more about vcpkg telemetry at docs/about/privacy.md
ljx@ljx-Lenovo:~/soft/vcpkg$ ./vcpkg integrate install
Applied user-wide integration for this vcpkg root.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/ljx/soft/vcpkg/scripts/buildsystems/vcpkg.cmake"

 

  命令执行过程如上图,应该是没问题的。

  但我在执行./vcpkg install realsense2的时候报错:

-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:72 (message):
    Command failed: /home/ljx/soft/vcpkg/downloads/tools/cmake-3.17.2-linux/cmake-3.17.2-Linux-x86_64/bin/cmake /home/ljx/soft/vcpkg/buildtrees/realsense2/src/93b7ff8597-4347a45ee5.clean -DBUILD_WITH_TM2=OFF -DENFORCE_METADATA=ON -DBUILD_WITH_OPENMP=OFF -DBUILD_UNIT_TESTS=OFF -DBUILD_WITH_STATIC_CRT=0 -DBUILD_OPENNI2_BINDINGS=OFF -DOPENNI2_DIR=/home/ljx/soft/vcpkg/installed/x64-linux/include/openni2 -DCMAKE_MAKE_PROGRAM=/home/ljx/soft/vcpkg/downloads/tools/ninja-1.10.0-linux/ninja -DCMAKE_SYSTEM_NAME=Linux -DBUILD_SHARED_LIBS=OFF -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/home/ljx/soft/vcpkg/scripts/toolchains/linux.cmake -DVCPKG_TARGET_TRIPLET=x64-linux -DVCPKG_SET_CHARSET_FLAG=ON -DVCPKG_PLATFORM_TOOLSET=external -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON -DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON -DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE -DCMAKE_VERBOSE_MAKEFILE=ON -DVCPKG_APPLOCAL_DEPS=OFF -DCMAKE_TOOLCHAIN_FILE=/home/ljx/soft/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON -DVCPKG_CXX_FLAGS= -DVCPKG_CXX_FLAGS_RELEASE= -DVCPKG_CXX_FLAGS_DEBUG= -DVCPKG_C_FLAGS= -DVCPKG_C_FLAGS_RELEASE= -DVCPKG_C_FLAGS_DEBUG= -DVCPKG_CRT_LINKAGE=dynamic -DVCPKG_LINKER_FLAGS= -DVCPKG_TARGET_ARCHITECTURE=x64 -DCMAKE_INSTALL_LIBDIR:STRING=lib -DCMAKE_INSTALL_BINDIR:STRING=bin -D_VCPKG_ROOT_DIR=/home/ljx/soft/vcpkg -D_VCPKG_INSTALLED_DIR=/home/ljx/soft/vcpkg/installed -DVCPKG_MANIFEST_INSTALL=OFF -DBUILD_EXAMPLES=OFF -DBUILD_GRAPHICAL_EXAMPLES=OFF -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/ljx/soft/vcpkg/packages/realsense2_x64-linux
    Working Directory: /home/ljx/soft/vcpkg/buildtrees/realsense2/x64-linux-rel
/home/ljx/soft/vcpkg/buildtrees/realsense2/x64-linux-rel Error code: 1 See logs for more information: /home/ljx/soft/vcpkg/buildtrees/realsense2/config-x64-linux-rel-out.log /home/ljx/soft/vcpkg/buildtrees/realsense2/config-x64-linux-rel-err.log Call Stack (most recent call first): scripts/cmake/vcpkg_configure_cmake.cmake:319 (vcpkg_execute_required_process) ports/realsense2/portfile.cmake:29 (vcpkg_configure_cmake) scripts/ports.cmake:79 (include) Error: Building package realsense2:x64-linux failed with: BUILD_FAILED Please ensure you're using the latest portfiles with `.\vcpkg update`, then submit an issue at https://github.com/Microsoft/vcpkg/issues including: Package: realsense2:x64-linux Vcpkg version: 2020.06.15-unknownhash Additionally, attach any relevant sections from the log files above.

    我复制保留了执行./bootstrap-vcpkg.sh 的时候下载的3个包:cmake、librealsense、ninja,(在vcpkg/downloads里面),清除vcpkg文件夹,

  重新按那几条指令顺序走一遍,在执行./bootstrap-vcpkg.sh 之前把三个下好的包放回对应的文件夹(纯粹是因为这样不用漫长的等待),

  好了,依旧是最后一步出错。

 

    然后我想能不能不用vcpkg这个C++包管理器安装,毕竟我已经通过它下载好了librealsense。

  于是我找到了https://github.com/IntelRealSense/librealsense/blob/v2.38.0/doc/installation.md,看到了Building librealsense2 SDK,看到了cmake……

  接着解压刚才下载好的IntrlRealSense-librealsense

  一顿操作:

 

mkdir build
cd build
cmake ../ -DCMAKE_BUILD_TYPE=Release
sudo make uninstall && make clean && make && sudo make install

 

  等待一段时间,输入sudo密码继续安装完成,就好了

 

  

 

  项目成功include啦!

  至此,librealsense安装完成。

 

  你以为的困难,不一定就真的难。

posted @ 2020-08-04 16:45  Json2019  阅读(2537)  评论(0编辑  收藏  举报