在 64 位 linux armv8 机器上编译 32 位二进制文​​件时遇到问题 [英] Having trouble compiling 32-bit binary on 64-bit linux armv8 machine

查看:37
本文介绍了在 64 位 linux armv8 机器上编译 32 位二进制文​​件时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Jetson Tx2 上使用 c++ ARM 32 位库,Jetson Tx2 是 ARM 64 位 linux 机器.当我尝试编译库提供的一些示例代码时,出现以下编译错误:

I am trying to use a c++ ARM 32-bit library on a Jetson Tx2, which is an ARM 64-bit linux machine. When I try to compile some of the sample code provided with the library I get the following compilation error:

/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 位机器不兼容.

I assume that this error is because the 32-bit library is somehow incompatible with a 64-bit machine.

我一直在浏览其他 StackOverflow 论坛上的类似问题,并根据这些论坛的建议在编译时将 -m32 标志添加到 CXXFLAGS 和 LDFLAGS.但是,我随后收到以下错误:

I have been browsing other StackOverflow forums on similar issues, and in accordance with those forum recommendations added the -m32 flag to CXXFLAGS and LDFLAGS when I compile. However, I then get the following error:

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 标志,必须运行以下命令:

Some other StackOverflow threads said that in order to use the -m32 flag, one has to run the command:

sudo apt-get install g++-multilib

我认为安装工作不正常,因为我收到以下错误:

I don't think that the installation is working correctly, as I'm getting the following errors:

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.

任何建议将不胜感激.谢谢!

Any suggestions would be very much appreciated. Thanks!

更新: 我意识到 -m32 标志仅在 x86 linux 机器上受支持.有谁知道ARM机器是否有一些等价物?

UPDATE: I realized that the -m32 flag is only supported on x86 linux machines. Does anyone know if there is some equivalent for ARM machines?

推荐答案

我查看了 GCC 文档,尤其是以下页面:

I had a look at the GCC documentation, especially on the following pages:

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 位代码.

Looks like for the GNU compilers x86 is one type of CPU; you can create 16-, 32- or 64-bit code for this CPU type.

但是对于 GNU 编译器来说,32 位 ARM CPU 和 64 位 ARM CPU 看起来也是两种完全不同的 CPU 类型.

However it also looks like for the GNU compilers 32-bit ARM CPUs and 64-bit ARM CPUs are two completely different CPU types.

因此,使用 64 位 ARM 编译器为 32 位 ARM 编译与使用 ARM 编译器为 x86 编译相同:它不起作用.

Therefore compiling for 32-bit ARM with a 64-bit ARM compiler is the same as compiling for x86 with an ARM compiler: It won't work.

当然不接受32位库;ARM 编译器也不接受 x86 库.

Of course the 32-bit library will not be accepted; an ARM compiler would not accept a x86 library, either.

这篇关于在 64 位 linux armv8 机器上编译 32 位二进制文​​件时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆