在 64 位 Linux armv8 计算机上编译 32 位二进制文件时遇到问题
Having trouble compiling 32-bit binary on 64-bit linux armv8 machine
我正在尝试在Jetson Tx2上使用C ++ ARM 32位库,这是一台ARM 64位Linux机器。当我尝试编译库提供的一些示例代码时,出现以下编译错误:
/usr/bin/ld: skipping incompatible /home/nvidia/libroyale/bin/libroyale.so
when searching for -lroyale
/usr/bin/ld: cannot find -lroyale
collect2: error: ld returned 1 exit status
CMakeFiles/sampleCameraInfo.dir/build.make:94: recipe for target
'sampleCameraInfo' failed
make[2]: *** [sampleCameraInfo] Error 1
CMakeFiles/Makefile2:67: recipe for target
'CMakeFiles/sampleCameraInfo.dir/all' failed
make[1]: *** [CMakeFiles/sampleCameraInfo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
我假设此错误是因为 32 位库与 64 位机器不兼容。
我一直在浏览其他关于类似问题的 StackOverflow 论坛,并根据这些论坛的建议在编译时将 -m32 标志添加到 CXXFLAGS 和 LDFLAGS 中。但是,我随后收到以下错误:
g++: error: unrecognized command line option ‘-m32’
CMakeFiles/sampleCameraInfo.dir/build.make:62: recipe for target
'CMakeFiles/sampleCameraInfo.dir/sampleCameraInfo.cpp.o' failed
make[2]: *** [CMakeFiles/sampleCameraInfo.dir/sampleCameraInfo.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target
'CMakeFiles/sampleCameraInfo.dir/all' failed
make[1]: *** [CMakeFiles/sampleCameraInfo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
其他一些 StackOverflow 线程说,为了使用 -m32 标志,必须运行以下命令:
sudo apt-get install g++-multilib
我认为安装无法正常工作,因为我收到以下错误:
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
g++-multilib:armhf : Depends: cpp:armhf (>= 4:5.3.1-1ubuntu1) but it is
not going to be installed
Depends: gcc-multilib:armhf (>= 4:5.3.1-1ubuntu1) but it is not going to be installed
Depends: g++:armhf (>= 4:5.3.1-1ubuntu1) but it is not going to be installed
Depends: g++-5-multilib:armhf (>= 5.3.1-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
任何建议将不胜感激。谢谢!
更新:我意识到 -m32 标志仅在 x86 Linux 机器上受支持。有谁知道ARM机器是否有一些等效物?
我看了一下 GCC 文档,尤其是在以下页面上:
https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/x86-Options.html
https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/AArch64-Options.html
看起来对于GNU编译器来说,x86是一种类型的CPU;你可以为这种CPU类型创建16位、32位或64位代码。
然而,对于GNU编译器来说,32位ARM CPU和64位ARM CPU是两种完全不同的CPU类型。
因此,使用 64 位 ARM 编译器编译 32 位 ARM 与使用 ARM 编译器编译 x86 相同:它不起作用。
当然,32位库不会被接受;ARM编译器也不会接受x86库。
相关文章:
- 正在读取二进制文件(is_open)
- 在C++中将类(带有Vector成员)保存为二进制文件
- 如何从二进制文件中读取字符串
- 保存/加载大量短数组到二进制文件
- 从二进制文件中读取整数数组
- Android 在编译二进制文件时重建静态库
- 在 C++ 中将双精度变量写入二进制文件
- clang 的 libFuzzer 可以在同一二进制文件中测试超过 1 个 API 吗?
- C++:实际上不是从二进制文件中读取
- 如何从二进制文件中的给定符号中获取调用程序图
- 将内部带有矢量的结构保存/读取到二进制文件中
- 编译多个C++文件.调用二进制文件以运行代码
- 如何使用位字段将数据从二进制文件复制到结构中?
- uint8_t同一二进制文件的不同十进制值
- C++单个生成文件多个二进制文件
- 尝试将数字写入二进制文件时引发异常
- C++中读/写二进制文件
- 如何忽略某些二进制文件的执行?
- 对在不同二进制文件中创建的对象文件的依赖关系
- 在 64 位 Linux armv8 计算机上编译 32 位二进制文件时遇到问题