GCC Cross compile to a i586 architecture (Vortex86DX)

纵然是瞬间 提交于 2020-01-28 10:21:48

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/32781281/gcc-cross-compile-to-a-i586-architecture-vortex86dx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!