GCC Cross编译成i586架构(Vortex86DX) [英] GCC Cross compile to a i586 architecture (Vortex86DX)
问题描述
我使用gcc 4.8.2的Ubuntu 12.01,并希望为运行旧的2.6.23内核的Vortex86DX CPU进行交叉编译。
我正在尝试以下测试代码:
#include< iostream>
int main()
{
std :: cout<< Hello world<<的std :: ENDL;
}
这是使用以下命令行编译的:
g ++ -static-libgcc -static-libstdc ++ -march = i586 test.cpp -otest586
当我在目标架构上运行test586时,出现此错误:
$ ./test586
./teste586:符号查找错误:./test586:undefined symbol:_ZMSbIwSt11char_traitsIwESaIwEE4_Rep20_S_empty_rep_storageE
关于这里发生了什么的任何想法?这只是一个小代码 - 真正的代码有大约10个不同的库,全都用C ++ 11编写。
事实上,马可的评论是对的。该代码仍然需要一些动态库:
$ ldd ./test586
linux-gate.so.1 => ; (0xb776b000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6(0xb75a4000)
/lib/ld-linux.so.2(0xb776e000)
我必须避免所有动态库,因为目标系统或者没有它们,或者会有一个非常旧的版本。
帮助我们完成这项工作。 我认为这个问题是命令开关的顺序,即链接器首先发现依赖关系(libgcc,libstdc ++),然后才解析它们。
如果您在发现依赖项之前先给它指定了-static-libgcc,那么它会简单地忽略它。
下面的代码适用于我:
$ g ++ -m32 -march = i586 test.cpp -o test586 -static -static-libgcc -static-libstdc ++
$ .// test586
Hello world
$ ldd test586
不是动态可执行文件
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;
}
That is compiled using the following command line:
g++ -static-libgcc -static-libstdc++ -march=i586 test.cpp -otest586
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
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.
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)
I have to avoid all dynamic library as the target system either does not have them or will have in a very old version.
Help appreciated to accomplish that.
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.
the following works for me:
$ g++ -m32 -march=i586 test.cpp -o test586 -static -static-libgcc -static-libstdc++
$ ./test586
Hello world
$ ldd test586
not a dynamic executable
这篇关于GCC Cross编译成i586架构(Vortex86DX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!