Jetson 系列——jetson xavier nx三率代码编译链接流程

27 篇文章 1 订阅
19 篇文章 2 订阅

c++代码所需要的基础

  1. cuda
  2. cudnn
  3. c++代码所需要的额外库,比如json,curl等

第一步:

cuda和cudnn,jetson Xavier自带cuda和cudnn,查看其版本号
查看cuda版本

nvcc -V

如果此时出现
nvcc : command not found
请在terminal中输入如下命令

export LD_LIBRARY_PATH=/usr/local/cuda/lib
export PATH=$PATH:/usr/local/cuda/bin

查看cudnn版本

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

可以看到对应的版本。
在这里插入图片描述
在这里插入图片描述

比如在本机jetson xavier nx上,cuda版本是10.2,cudnn版本是8.0。
(更新,在windows上使用了libtorch,但是在linux上,使用的是tensorrt,因此不需要安装libtorch,直接跳过libtorch安装步骤即可)

第二步,先测试编译链接,查看错误的地方

cmake -D CMAKE_BUILD_TYPE=RELEASE ..
make

错误1

如果发现jsoncurl未安装,需要安装jsoncurl等库
下面是json库的安装流程:linux json库的安装流程
下面是curl安装流程:linux curl 安装流程

补丁

当加入了onvif代码之后,不要sudo直接安装libcurl4-openssl-dev,会和libssl1.0-dev冲突,可以安装curl,因此还是下载curl安装
curl版本是7.51.0 官网地址https://curl.se/download/
https://curl.se/download/curl-7.51.0.tar.bz2
curl安装流程
同时安装openssl

sudo apt-get install libssl1.0-dev

错误2fatal error : lame/lame.h no such file or directory

安装下面说明安装
lame linux记录录音

错误3:

glog/logging.h: 没有那个文件或目录
eyes@eyes-desktop:~/project/clda_nano_copy/build$ make
[  6%] Building CXX object CMakeFiles/wl.dir/factory/src/analyser.cpp.o
[ 13%] Building CXX object CMakeFiles/wl.dir/factory/src/fs.cpp.o
In file included from /home/eyes/project/clda_nano_copy/factory/src/fs.cpp:17:0:
/home/eyes/project/clda_nano_copy/factory/include/workloop/logging.hpp:9:10: fatal error: glog/logging.h: 没有那个文件或目录
 #include "glog/logging.h"
          ^~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/wl.dir/build.make:89: recipe for target 'CMakeFiles/wl.dir/factory/src/fs.cpp.o' failed
make[2]: *** [CMakeFiles/wl.dir/factory/src/fs.cpp.o] Error 1
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/wl.dir/all' failed
make[1]: *** [CMakeFiles/wl.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2

解决方法

//安装
sudo apt-get install libgoogle-glog-dev
//卸载
sudo apt-get remove libgoogle-glog-dev

错误4cannot find lxxxxx

查找文件

sudo find / -name xxxxx

这说明以下库文件链接有问题,也就是find后面的参数中,l的后面就是库文件的名字,不过需要手动在名字前补齐lib
如:

cannot find -lcudart
cannot find -lnppc
cannot find -lnppi
cannot find -lnppc
cannot find -lnpps

就是

libcudart
libnppc
libnppi
libnppc
libnpps

usr/lib目录下没有这些文件
cannot find -lcudart

find / -name "libcudart*"
cp xx/libcudart.so /usr/lib

直接在系统根目录中依次搜索这些库文件,并使用

sudo cp 库文件名 /usr/lib

命令将相应库文件拷贝到该目录中即可

错误5 cannot find -lavcodec -lavformat -lavutil -lswresample

这几个库是ffmpeg的库,只需要安装dev就可以了

sudo apt install libavformat-dev
sudo apt install libavcodec-dev
sudo apt install libswresample-dev
sudo apt install libswscale-dev
sudo apt install libavutil-dev
sudo apt install libsdl1.2-dev

一般装一个,其他的都会自动帮你装上

错误6cannot find -lnvrtc

首先使用find查找位置

find / -name libnvrtc.so

查找到

/usr/local/cuda-10.2/targets/aarch64-linux/lib/libnvrtc.so

这时候需要到/usr/lib做一个软连接

sudo ln -s /usr/local/cuda-10.2/targets/aarch64-linux/lib/libnvrtc.so /usr/lib/libnvrtc.so
sudo ldconfig

然后make就可以了

随后继续编译连接直到不报错为止。

随后输入

./clda

查看代码正常运行

注意 opencv4.1.1

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值