libgflags.a(gflags.cc.o): relocation R_AARCH64_ADR_PREL_PG_HI21

这个问题的解决废了好大功夫,最后google很多论坛才找到方法,特此记录,给大家节省时间

完整版本报错:

bash 复制代码
/usr/bin/ld: /usr/local/lib/libgflags.a(gflags.cc.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZN22gflags_mutex_namespace5MutexD1Ev' which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libgflags.a(gflags.cc.o): in function `google::(anonymous namespace)::FlagRegistry::GlobalRegistry()':
gflags.cc:(.text+0x1908): dangerous relocation: unsupported relocation
/usr/bin/ld: /usr/local/lib/libgflags.a(gflags.cc.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EED1Ev' which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libgflags.a(gflags.cc.o): in function `_GLOBAL__sub_I__ZN3fLS14FLAGS_flagfileB5cxx11E':
gflags.cc:(.text.startup+0x2c0): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
make[2]: *** [modules/sfm/CMakeFiles/opencv_sfm.dir/build.make:242: lib/libopencv_sfm.so.4.5.4] Error 1
make[1]: *** [CMakeFiles/Makefile2:8569: modules/sfm/CMakeFiles/opencv_sfm.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

静态库的链接出问题了,我们重新编译一下并且编译成动态库就好了。

解决方法:重新编译ffmpeg

bash 复制代码
cd .. && git clone https://github.com/ffmpeg/ffmpeg && cd ffmpeg
./configure --enable-pic -DBUILD_SHARED_LIBS=ON && make && make install

对于在Orin上面的库报错:

cpp 复制代码
undefined reference to `v4l2_open'
undefined reference to `v4l2_mmap'
undefined reference to `v4l2_munmap'
undefined reference to `v4l2_close'

需要在CMakeLists.txt里面手动target_link_libraries链接 v4l1 v4l2(x86平台不需要,我也没搞懂为啥)

相关推荐
wang6021252181 分钟前
Git部署项目配置密钥-Linux系统
linux·运维·git
xlp666hub3 分钟前
链表与它在 Linux 内核中的实现
linux·数据结构
倔强的石头10620 分钟前
【Linux指南】进程控制系列(四)进程替换 ——exec 系列函数全解析与应用
linux·运维·bash
悾说22 分钟前
xRDP实现Linux图形化通过Windows RDP访问Linux远程桌面
linux·运维·windows
tianyuanwo44 分钟前
解决Anolis/CentOS 8下Python 3.11 SELinux模块缺失:从原理到实战的完整指南
linux·centos·python3.11
承渊政道1 小时前
Linux系统学习【Linux基础指令以及权限问题】
linux·服务器·学习
一个人听秋雨1 小时前
speedtest-x脚本优化
linux·运维
食咗未1 小时前
Linux SSH工具的使用
linux·网络·测试工具·ssh·远程登陆
HalvmånEver1 小时前
Linux:深入剖析 System V IPC下(进程间通信九)
linux·运维·服务器·c++·system v·管道pipe
AI+程序员在路上1 小时前
Linux网桥内核配置与使用
linux·网络