Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi all,
I'm a newbie in Linux programming. I compile the "Hello world program" by means of gcc compiler in a Centos 6 host computer, with kernel 2.6.32. The command line used is gcc -static hello.c -ohello. Previously I have installed the GNUlibc (ver 2.12) in this computer.
The compile process is ok, and runs ok in the host computer (Pentium 4). When I copy the program to an embedded cpu with AMD GEODE LX800 processor and kernel 2.6.12, the running result is "error: illegal instruction"

I checked compile with different parameters in gcc command line: -mpc64, -m32, -march=i386, -march=geode with no results with any of them (compile is ok but running error "illegal instrucion")
I know a cross compiling is neccesary but don´t know the correct parameters to gcc to use

The code is as simple as this
main()
{
printf("Hello world\n");
}
Posted
Comments
RedDk 23-Oct-13 18:22pm    
Repost
Andreas Gieriet 23-Oct-13 18:40pm    
Have you tried without -static?
Cheers
Andi
Member 10341933 24-Oct-13 6:42am    
2 comments and two questions about the problem:
- both host and target run in 32-bit linux
- both host and target run in X86 box
Do I need to build a specific cross-compile toolchain? or instead is enough with standard gcc
Do I need to use a makefile? or is enough using the gcc command line

This is the indication of the fact that two different system are targeted to different instruction set architectures of the CPU, and the CPU could be different, or it could be different situation: the CPU are the same, but on one of the OS, it works in 32-bit compatibility mode and does not support one of the 64-bit architectures you compiled your code on. Please check up.

Please see: http://en.wikipedia.org/wiki/Instruction_set[^].

If you need some more concrete detail, you have to figure up to four facts: what is the exact CPU model (if you don't know it instruction set architecture), what is the target platform of the OS version, and this information should be provided for both systems. I think if you get this information, you well see by yourself what was wrong. And then you may need to cross-compile your code for different platform.

—SA
 
Share this answer
 
v3
Have a look at http://en.wikipedia.org/wiki/Cross_compiler#GCC_and_cross_compilation[^]. Maybe this helps in setting up the environment for cross compilation.
Cheers
Andi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900