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平台不需要,我也没搞懂为啥)

相关推荐
handler0114 分钟前
Linux: 基本指令知识点(2)
linux·服务器·c语言·c++·笔记·学习
liuyukuan28 分钟前
如何在win11上打开 WSL2(Windows 的 Linux 子系统)?
linux·windows
橙子也要努力变强1 小时前
Linux信号机制
linux·服务器·网络
shughui1 小时前
FinalShell / Xshell 完整教程(下载+安装+使用,2026最新版)
linux·fiddler·xshell·xftp·finalshell·远程连接工具
程序猿编码1 小时前
给你的网络流量穿件“隐形衣“:手把手教你用对称加密打造透明安全隧道
linux·开发语言·网络·安全·linux内核
pengyi8710152 小时前
私网IP映射公网基础原理,搭配代理IP远程访问入门
linux·服务器·网络
深圳市九鼎创展科技2 小时前
MT8883 vs RK3588 开发板全面对比:选型与场景落地指南
大数据·linux·人工智能·嵌入式硬件·ubuntu
RisunJan3 小时前
Linux命令-ngrep(方便的数据包匹配和显示工具)
linux·运维·服务器
.千余3 小时前
【Linux】基本指令3
linux·服务器·开发语言·学习
热爱Liunx的丘丘人4 小时前
Ansible-doc及常用模块
linux·运维·服务器·ansible