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

相关推荐
whyutianict_vv10 分钟前
云计算 HCIE 认证体系解析:HCIA/HCIP/HCIE 三级科目与知识边界
linux·运维·云计算
0+1117 小时前
Linux --从 poll 到 epoll多路转接
linux·服务器·1024程序员节
青瓦梦滋7 小时前
WebSocket协议
linux·服务器·网络·c++·websocket·网络协议·http
2601_9498477510 小时前
bcrypt.js 跨端三方库仓颉适配全流程
linux·运维·ubuntu
m0_6399069410 小时前
Linux 操作系统入门:目录结构、服务排查常用命令、Shell 脚本基础
linux·运维·后端
水饺编程12 小时前
第2章:Linux 基础,exit 命令
linux·c语言·汇编
木子欢儿12 小时前
Debian 13 + vsftpd 搭建FTP服务
linux·服务器·前端·网络·debian
GeW13 小时前
新质生产力落地实践:企业级Linux迁移与数据库国产化
linux
雯宝14 小时前
usb_serial_generic_register
linux
疯狂的Meng14 小时前
我把第一周的 Linux 命令整理成了自己的手册(附 7 个我踩的坑)
linux