GCC 交叉编译为 i586 架构 (Vortex86DX)

GCC Cross compile to a i586 architecture (Vortex86DX)(GCC 交叉编译为 i586 架构 (Vortex86DX))

本文介绍了GCC 交叉编译为 i586 架构 (Vortex86DX)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带有 gcc 4.8.2 的 Ubuntu 12.01,并希望针对运行旧 2.6.23 内核的 Vortex86DX CPU 进行交叉编译.

I have Ubuntu 12.01 with gcc 4.8.2 and would like to cross compile for the Vortex86DX CPU running an old 2.6.23 kernel.

我正在尝试以下测试代码:

I´m trying the following testing code:

#include <iostream>

int main()
{
   std::cout << "Hello world" << std::endl;
}

使用以下命令行编译:

g++ -static-libgcc -static-libstdc++ -march=i586 test.cpp -otest586

当我在目标架构上运行 test586 时,我收到了这个错误:

When I run the test586 on the target architecture I´m getting this error:

$ ./test586
./teste586: symbol lookup error: ./test586: undefined symbol: _ZMSbIwSt11char_traitsIwESaIwEE4_Rep20_S_empty_rep_storageE

对这里发生的事情有任何想法吗?这只是一个小代码——真正的代码有大约 10 个不同的库,全部用 C++ 11 编写.

Any ideas of what is going on here ? This is just a small code - the real code has around 10 different libraries all written in C++ 11.

事实上,Marco 的评论是对的.代码还需要一些动态库:

In fact the comment from Marco was right. The code still need some dynamics libraries:

$ ldd ./test586
linux-gate.so.1 =>  (0xb776b000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb75a4000)
/lib/ld-linux.so.2 (0xb776e000)

我必须避免 all 动态库,因为目标系统要么没有它们,要么将具有非常旧的版本.

I have to avoid all dynamic library as the target system either does not have them or will have in a very old version.

帮助实现这一目标.

推荐答案

我认为问题在于命令切换的顺序,即链接器首先发现依赖项(libgcc,libstdc++),然后才解决它们.如果你在它找到依赖之前给它 -static-libgcc 那么它会简单地忽略它.

I think the problem is the order of the command switches, i.e. the linker first discovers the dependencies (libgcc, libstdc++) and only then resolves them. If you give it -static-libgcc before it found the dependency then it will simply ignore it.

以下对我有用:

$ g++ -m32 -march=i586 test.cpp -o test586 -static -static-libgcc -static-libstdc++
$ ./test586 
Hello world
$ ldd test586 
not a dynamic executable

这篇关于GCC 交叉编译为 i586 架构 (Vortex86DX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:GCC 交叉编译为 i586 架构 (Vortex86DX)

基础教程推荐