Cannot compile HelloWorld with OpenEmbedded LinuxV2.6

Hello,
I try to compile the simple application Hello World :
http://developer.toradex.com/knowledge-base/hello-world-application-on-embedded-linux#Hello_World_Application_using_Text_Editor_and_Linux_Terminal

For this I use OpenEmbedded Core with LinuxImageV2.6
http://developer.toradex.com/knowledge-base/board-support-package/openembedded-(core)

With the variable

export ARCH=arm
export CROSS_COMPILE=arm-angstrom-linux-gnueabi-  
export PATH=~/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/bin:~/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/bin/arm-angstrom-linux-gnueabi/:$PATH 

I have this problem with the following cmd :

fiveco$ ${CROSS_COMPILE}gcc -mfloat-abi=hard -o hello_world hello_world.c
hello_world.c:1:64: fatal error: stdio.h: No such file or directory
compilation terminated.

If I add the linker to apalis-imx6/usr/include, I have the following problem :

${CROSS_COMPILE}gcc -I/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/apalis-imx6/usr/include -mfloat-abi=hard -o hello_world hello_world.c
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot open crt1.o: No such file or directory
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot open crti.o: No such file or directory
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot open crtbegin.o: No such file or directory
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot open crtend.o: No such file or directory
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot open crtn.o: No such file or directory
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot find -lgcc
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot find -lgcc_s
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot find -lc
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot find -lgcc
/home/fiveco/Programmes/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/ld: error: cannot find -lgcc_s
/tmp/cchHvOGa.o:hello_world.c:function main: error: undefined reference to 'puts'
collect2: error: ld returned 1 exit status

Why ld didn’t find crt1.o and other files located in oe-core/build/out-glibc/sysroots/apalis-imx6/usr/lib/ ?

Yes, later compilers like gcc 5.2 require you to specify a sysroot as well e.g. as follows:

[user@host ~]$ export CROSS_COMPILE=~/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-
[user@host ~]$ ${CROSS_COMPILE}gcc --sysroot=${HOME}/oe-core/build/out-glibc/sysroots/apalis-t30 -mfloat-abi=hard -o hello_world hello_world.c

Edit: use ${HOME} instead of ~ to specify the sysroot path. At least some shells seem to not expand ~ to the user’s home directory in that use case.

Thanks for your answer. Did you know how to add sysroot parameter in Eclipse cross-compile parameters ?

It can be specified in Project → Properties–>C/C++ Build–>Settings–>Cross GCC Compiler–>Miscellaneous–>Other flags.

I have to put in the Miscellaneous of “Cross GCC Linker” too

I am trying to run hello world example project in colibrivf61 with 2.6 image. The error still occurs after including sysroot. Please help

akn@akn-Vostro-2420:~/hello_world$ export CROSS_COMPILE=~/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-

akn@akn-Vostro-2420:~/hello_world$ ${CROSS_COMPILE}gcc --sysroot=~/oe-core/build/out-glibc/sysroots/colibri-vf -mfloat-abi=hard -o hello_world hello_world.c

hello_world.c:1:64: fatal error: stdio.h: No such file or directory
compilation terminated.
akn@akn-Vostro-2420:~/hello_world$

I have the same problem with colibri T30. Here my steps (after successfully building angstrom-lxde-image):

cd hello_world
export ARCH=arm
export PATH=~/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/bin:~/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/bin/arm-angstrom-linux-gnueabi/:$PATH
export CROSS_CoMPILE=arm-angstrom-linux-gnueabi-
${CROSS_CoMPILE}gcc --sysroot=~/oe-core/build/out-glibc/sysroots/colibri-t30 -mfloat-abi=hard -o hello_world hello_world.c

Do I miss something?

EDIT: removed the first and redundatn “export CROSS_CoMPILE” statement.

OK, thanks for letting us know.

@lmoellendorf

Hi

When tried now stdio.h wasn’t found too on my home PC.
Giving the full path to --sysroot fixed the issue for me.
e.g.

${CROSS_CoMPILE}gcc --sysroot=${HOME}/oe-core/build/out-glibc/sysroots/colibri-t30 -mfloat-abi=hard -o hello_world hello_world.c

Max

Thank you, this solved it!

I think the reason is that ~ is not expanded in this case. See http://stackoverflow.com/a/11587409

EDIT: Never mind, I saw your EDIT of your Answer just now.