Our test.c file is:
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
void main()
{
int fd;
fd= open("file1.txt",O_CREAT | O_WRONLY,0600);
// fd= open("/dev/ttyS0",O_RDONLY);
close(fd);
}
gcc test.c --sysroot=/opt/fsl-networking/QorIQ-SDK-V1.7/sysroots/ppce500v2-fsl-linux-gnuspe/ -o test.c
We compiled the test.c file using the above command, and when trying to execute on the target we are getting the following error:
-sh: ./test: cannot execute binary file: Exec format error
When we run this binary on Linux host, it is working(it creates a new file "file1.txt"), does it mean it just compiled not cross-compile?
Thanks,
Use the following command sequence:
sudo chmod 777 /opt/fsl-networking/QorIQ-SDK-V1.7/environment-setup-ppce500v2-fsl-linux-gnuspe
source /opt/fsl-networking/QorIQ-SDK-V1.7/environment-setup-ppce500v2-fsl-linux-gnuspe
powerpc-fsl-linux-gnuspe-gcc test.c --sysroot=/opt/fsl-networking/QorIQ-SDK-V1.7/sysroots/ppce500v2-fsl-linux-gnuspe/ -o test.elf
Look at setting in the "environment-setup-ppce500v2-fsl-linux-gnuspe" file.
Have a great day,
Pavel Chubakov
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
We got the cross-compilation working now.
The command that is used is : $CC test.c -o test
Here CC is the variable value that is available after sourcing environment setup file.
Thanks,