Hello world program using linaro in VF61

I have installed linaro cross tool chain as described in article “How to setup environment for Embedded Linux application development” , I wish to cross compile a simple program using this tool chain, which method i should follow for this

It would be recommended to set up a SDK and then build your application using the toolchain from the SDK and the sysroots.

For compiling an application, a Makefile like below can be used

SYSROOTS ?= /usr/local/oecore-x86_64/sysroots
CC = ${SYSROOTS}/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-gcc
INCLUDES = -I${SYSROOTS}/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/usr/include
LIB_PATH = -L${SYSROOTS}/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/lib
LIBS = -lpthread
CFLAGS = -O2 -g -Wall -mfloat-abi=hard --sysroot=${SYSROOTS}/armv7at2hf-vfp-neon-angstrom-linux-gnueabi

all:
	${CC} ${CFLAGS} ${INCLUDES} ${LIB_PATH} ${LIBS} hello.c -o hello

clean:
	rm -rf hello

Note that a simple hello world application does not need to link against pthreads library but I have included it just for example.

I have used the toolchain from the SDK build from OE but one change the CC to point to the external Linaro toolchain. For a quick test, you may also build the hello world application as follows using Linaro toolchain.

~/gcc-linaro/bin/arm-linux-gnueabihf-gcc hello.c -o hello

Note that the above will only work for hello world application as it does not have external library dependencies.

Thank you for your great support, Still I made a mistake, Instead of using OE SDK make file, I used makefile from
Single Board Computers (SBCs), Computer on Modules, System on Modules , in that sample project “Makefile.ExtToolchain_Rootfs”, I used it as my Make file, tried to compile gtk_scribble_V2 from eclips, ( as explained in ,
[1]: Hello World application on Embedded Linux (C/C++) | Toradex Developer Center
)

And got following error,


17:26:15 **** Build of configuration Default for project gtk_scribble_V2 ****
make all 
arm-linux-gnueabihf-gcc -c -O0 -g -Wall `pkg-config --cflags gtk+-2.0` -march=armv7-a -fno-tree-vectorize -mthumb-interwork -mfloat-abi=hard -mtune=cortex-a9 -Wno-poison-system-directories  -o scribble-simple.o scribble-simple.c
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
                 from /usr/include/glib-2.0/glib/gtypes.h:32,
                 from /usr/include/glib-2.0/glib/galloca.h:32,
                 from /usr/include/glib-2.0/glib.h:30,
                 from /usr/include/glib-2.0/gobject/gbinding.h:28,
                 from /usr/include/glib-2.0/glib-object.h:23,
                 from /usr/include/glib-2.0/gio/gioenums.h:28,
                 from /usr/include/glib-2.0/gio/giotypes.h:28,
                 from /usr/include/glib-2.0/gio/gio.h:26,
                 from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
                 from /usr/include/gtk-2.0/gdk/gdk.h:32,
                 from /usr/include/gtk-2.0/gtk/gtk.h:32,
                 from scribble-simple.c:21:
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
/usr/include/glib-2.0/glib/gmacros.h:232:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
                                                     ^
/usr/include/glib-2.0/glib/gmacros.h:229:47: note: in definition of macro 'G_PASTE_ARGS'
 #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
                                               ^
/usr/include/glib-2.0/glib/gmacros.h:232:44: note: in expansion of macro 'G_PASTE'
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
                                            ^
/usr/include/glib-2.0/glib/gtypes.h:422:3: note: in expansion of macro 'G_STATIC_ASSERT'
   G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
   ^
scribble-simple.c: At top level:
cc1: warning: unrecognized command line option '-Wno-poison-system-directories'
Makefile:77: recipe for target 'scribble-simple.o' failed
make: *** [scribble-simple.o] Error 1

17:26:16 Build Finished (took 322ms)

please help to debug this error

Before using the sample Makefile.ExtToolchain_Rootfs provided in the scribble example project, the macros OECORE_TARGET_SYSROOT and CROSS_COMPILE need to be updated according to current setup.

e.g.

 OECORE_TARGET_SYSROOT ?= $(HOME)/Colibri_VF_LinuxImageV2.6.1/rootfs/
 CROSS_COMPILE ?= $(HOME)/gcc-linaro/bin/arm-linux-gnueabihf-

Also one need to make sure to prepare the target rootfs shared objects to be ready for development as mentioned in article:

cd
cd workspace/gtk_scribble_V2
ln -s Makefile.ExtToolchain_Rootfs Makefile
cd /srv/nfs/rootfs/usr/lib
sudo sh -c "ls -w 1 | grep '\.so\.[0-9]*\.[0-9]*\.[0-9]*$' | sed -r 's/(.*\.so)(\.[0-9]*\.[0-9]*\.[0-9]*$)/ln -s \1\2 \1/' > makesymlinks.sh"
sudo chmod +x makesymlinks.sh
sudo ./makesymlinks.sh
sudo rm makesymlinks.sh

hi,

I was setting up Eclipse IDE , Usin OE Core SDK as per the following article

when I build the project I got the following error

Did you start eclipse IDE in the shell where you sourced the environment script ?

yes I did, still same error

I quickly rechecked using Eclipse IDE with oe-core SDK, it works as expected.
Can you please recheck your C/C++ build settings ?

this is the new error found, may be the exported path issue, A ctually I was trying to access snmp.h file situated in

/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/usr/include/linux

I found it was part of meta-networking layer, path variable not included

“sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/” folder and its sub directries,

The SDK which you build/use is for the standard evaluation Toradex image on which not all the packges which you are expecting are deployed. Ideally you will need to append your required packages to our the standard evaluation Toradex image recipe and build the SDK to that image so that the SDK will contain the libraries, headers & symbols of the packages selected in the image.

yes, it was an issue in addressing the header file, this was an irrelevant question,

or simply how van we add meta-networking layer headers in eclips includes