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

相关推荐
Nebula嵌入式13 小时前
【C语言】09-深入解析main函数
linux·c语言·开发语言·嵌入式
Dxy123931021614 小时前
Linux 编译安装 Python 3.12.10(多版本共存,不破坏系统Python)
linux·运维·python
xz驱动分享16 小时前
Linux DMA 子系统学习笔记
linux·dma·rk3588·嵌入式软件
w678200717 小时前
Prisma不能优雅的支持DTO,试试Vona ORM吧
linux·运维·ubuntu
Darkwanderor17 小时前
Linux系统编程实战项目:模拟实现shell
linux·c++
杨某不才19 小时前
如何能让Linux服务器对shell 终端 + sftp 文件传输长期保活
linux·运维·服务器
vance0419 小时前
免费Cloudflare隧道隐藏公网IP
linux·tcp/ip·github
杨云龙UP19 小时前
生产环境Oracle表空间扩容实战:使用Toad for Oracle图形界面新增Datafile(ASM+OMF)
linux·运维·数据库·oracle·表空间·asm 存储管理·toad
三言老师20 小时前
文本工具组合统计服务器日志数据
linux·运维·服务器
mounter62520 小时前
认识 Tetragon:基于 eBPF 的安全监控与强制执行工具
linux·ebpf·cve·kernel