109209eecSAndrew Geissler.. SPDX-License-Identifier: CC-BY-SA-2.0-UK 209209eecSAndrew Geissler 309209eecSAndrew Geissler******************************** 409209eecSAndrew GeisslerUsing the SDK Toolchain Directly 509209eecSAndrew Geissler******************************** 609209eecSAndrew Geissler 709209eecSAndrew GeisslerYou can use the SDK toolchain directly with Makefile and Autotools-based 809209eecSAndrew Geisslerprojects. 909209eecSAndrew Geissler 1009209eecSAndrew GeisslerAutotools-Based Projects 1109209eecSAndrew Geissler======================== 1209209eecSAndrew Geissler 1309209eecSAndrew GeisslerOnce you have a suitable :ref:`sdk-manual/intro:the cross-development toolchain` 147784c429SPatrick Williamsinstalled, it is very easy to develop a project using the :wikipedia:`GNU 157784c429SPatrick WilliamsAutotools-based <GNU_Build_System>` workflow, which is outside of the 167784c429SPatrick Williams:term:`OpenEmbedded Build System`. 1709209eecSAndrew Geissler 1809209eecSAndrew GeisslerThe following figure presents a simple Autotools workflow. 1909209eecSAndrew Geissler 2009209eecSAndrew Geissler.. image:: figures/sdk-autotools-flow.png 2109209eecSAndrew Geissler :align: center 22d583833aSAndrew Geissler :width: 70% 2309209eecSAndrew Geissler 2409209eecSAndrew GeisslerFollow these steps to create a simple Autotools-based "Hello World" 2509209eecSAndrew Geisslerproject: 2609209eecSAndrew Geissler 2709209eecSAndrew Geissler.. note:: 2809209eecSAndrew Geissler 2909209eecSAndrew Geissler For more information on the GNU Autotools workflow, see the same 3009209eecSAndrew Geissler example on the 3109209eecSAndrew Geissler GNOME Developer 3209209eecSAndrew Geissler site. 3309209eecSAndrew Geissler 34517393d9SAndrew Geissler#. *Create a Working Directory and Populate It:* Create a clean 3509209eecSAndrew Geissler directory for your project and then make that directory your working 36517393d9SAndrew Geissler location:: 3709209eecSAndrew Geissler 3809209eecSAndrew Geissler $ mkdir $HOME/helloworld 3909209eecSAndrew Geissler $ cd $HOME/helloworld 4009209eecSAndrew Geissler 4109209eecSAndrew Geissler After setting up the directory, populate it with files needed for the flow. 4209209eecSAndrew Geissler You need a project source file, a file to help with configuration, 4309209eecSAndrew Geissler and a file to help create the Makefile, and a README file: 4409209eecSAndrew Geissler ``hello.c``, ``configure.ac``, ``Makefile.am``, and ``README``, 4509209eecSAndrew Geissler respectively. 4609209eecSAndrew Geissler 4709209eecSAndrew Geissler Use the following command to create an empty README file, which is 48c926e17cSAndrew Geissler required by GNU Coding Standards:: 4909209eecSAndrew Geissler 5009209eecSAndrew Geissler $ touch README 5109209eecSAndrew Geissler 5209209eecSAndrew Geissler Create the remaining 5309209eecSAndrew Geissler three files as follows: 5409209eecSAndrew Geissler 55c926e17cSAndrew Geissler - ``hello.c``:: 5609209eecSAndrew Geissler 5709209eecSAndrew Geissler #include <stdio.h> 5809209eecSAndrew Geissler 5909209eecSAndrew Geissler main() 6009209eecSAndrew Geissler { 6109209eecSAndrew Geissler printf("Hello World!\n"); 6209209eecSAndrew Geissler } 6309209eecSAndrew Geissler 64c926e17cSAndrew Geissler - ``configure.ac``:: 6509209eecSAndrew Geissler 6609209eecSAndrew Geissler AC_INIT(hello,0.1) 6709209eecSAndrew Geissler AM_INIT_AUTOMAKE([foreign]) 6809209eecSAndrew Geissler AC_PROG_CC 6909209eecSAndrew Geissler AC_CONFIG_FILES(Makefile) 7009209eecSAndrew Geissler AC_OUTPUT 7109209eecSAndrew Geissler 72c926e17cSAndrew Geissler - ``Makefile.am``:: 7309209eecSAndrew Geissler 7409209eecSAndrew Geissler bin_PROGRAMS = hello 7509209eecSAndrew Geissler hello_SOURCES = hello.c 7609209eecSAndrew Geissler 77517393d9SAndrew Geissler#. *Source the Cross-Toolchain Environment Setup File:* As described 7809209eecSAndrew Geissler earlier in the manual, installing the cross-toolchain creates a 7909209eecSAndrew Geissler cross-toolchain environment setup script in the directory that the 8009209eecSAndrew Geissler SDK was installed. Before you can use the tools to develop your 8109209eecSAndrew Geissler project, you must source this setup script. The script begins with 8209209eecSAndrew Geissler the string "environment-setup" and contains the machine architecture, 8309209eecSAndrew Geissler which is followed by the string "poky-linux". For this example, the 8409209eecSAndrew Geissler command sources a script from the default SDK installation directory 8509209eecSAndrew Geissler that uses the 32-bit Intel x86 Architecture and the &DISTRO; Yocto 86c926e17cSAndrew Geissler Project release:: 8709209eecSAndrew Geissler 8809209eecSAndrew Geissler $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux 8909209eecSAndrew Geissler 9092b42cb3SPatrick Williams Another example is sourcing the environment setup directly in a Yocto 9192b42cb3SPatrick Williams build:: 9292b42cb3SPatrick Williams 9392b42cb3SPatrick Williams $ source tmp/deploy/images/qemux86-64/environment-setup-core2-64-poky-linux 9492b42cb3SPatrick Williams 95517393d9SAndrew Geissler#. *Create the configure Script:* Use the ``autoreconf`` command to 9692b42cb3SPatrick Williams generate the ``configure`` script:: 9709209eecSAndrew Geissler 9809209eecSAndrew Geissler $ autoreconf 9909209eecSAndrew Geissler 10009209eecSAndrew Geissler The ``autoreconf`` 10109209eecSAndrew Geissler tool takes care of running the other Autotools such as ``aclocal``, 10209209eecSAndrew Geissler ``autoconf``, and ``automake``. 10309209eecSAndrew Geissler 10409209eecSAndrew Geissler .. note:: 10509209eecSAndrew Geissler 1063b8a17c1SAndrew Geissler If you get errors from ``configure.ac``, which ``autoreconf`` 10709209eecSAndrew Geissler runs, that indicate missing files, you can use the "-i" option, 10809209eecSAndrew Geissler which ensures missing auxiliary files are copied to the build 10909209eecSAndrew Geissler host. 11009209eecSAndrew Geissler 111517393d9SAndrew Geissler#. *Cross-Compile the Project:* This command compiles the project using 11209209eecSAndrew Geissler the cross-compiler. The 11309209eecSAndrew Geissler :term:`CONFIGURE_FLAGS` 11409209eecSAndrew Geissler environment variable provides the minimal arguments for GNU 115c926e17cSAndrew Geissler configure:: 11609209eecSAndrew Geissler 11709209eecSAndrew Geissler $ ./configure ${CONFIGURE_FLAGS} 11809209eecSAndrew Geissler 11909209eecSAndrew Geissler For an Autotools-based 12009209eecSAndrew Geissler project, you can use the cross-toolchain by just passing the 12109209eecSAndrew Geissler appropriate host option to ``configure.sh``. The host option you use 12209209eecSAndrew Geissler is derived from the name of the environment setup script found in the 12309209eecSAndrew Geissler directory in which you installed the cross-toolchain. For example, 12409209eecSAndrew Geissler the host option for an ARM-based target that uses the GNU EABI is 12509209eecSAndrew Geissler ``armv5te-poky-linux-gnueabi``. You will notice that the name of the 12609209eecSAndrew Geissler script is ``environment-setup-armv5te-poky-linux-gnueabi``. Thus, the 12709209eecSAndrew Geissler following command works to update your project and rebuild it using 128c926e17cSAndrew Geissler the appropriate cross-toolchain tools:: 12909209eecSAndrew Geissler 13009209eecSAndrew Geissler $ ./configure --host=armv5te-poky-linux-gnueabi --with-libtool-sysroot=sysroot_dir 13109209eecSAndrew Geissler 132517393d9SAndrew Geissler#. *Make and Install the Project:* These two commands generate and 133c926e17cSAndrew Geissler install the project into the destination directory:: 13409209eecSAndrew Geissler 13509209eecSAndrew Geissler $ make 13609209eecSAndrew Geissler $ make install DESTDIR=./tmp 13709209eecSAndrew Geissler 13809209eecSAndrew Geissler .. note:: 13909209eecSAndrew Geissler 14009209eecSAndrew Geissler To learn about environment variables established when you run the 14109209eecSAndrew Geissler cross-toolchain environment setup script and how they are used or 1420903674eSAndrew Geissler overridden by the Makefile, see the 1430903674eSAndrew Geissler :ref:`sdk-manual/working-projects:makefile-based projects` section. 14409209eecSAndrew Geissler 14509209eecSAndrew Geissler This next command is a simple way to verify the installation of your 14609209eecSAndrew Geissler project. Running the command prints the architecture on which the 14709209eecSAndrew Geissler binary file can run. This architecture should be the same 148517393d9SAndrew Geissler architecture that the installed cross-toolchain supports:: 14909209eecSAndrew Geissler 15009209eecSAndrew Geissler $ file ./tmp/usr/local/bin/hello 15109209eecSAndrew Geissler 152517393d9SAndrew Geissler#. *Execute Your Project:* To execute the project, you would need to run 15309209eecSAndrew Geissler it on your target hardware. If your target hardware happens to be 154c926e17cSAndrew Geissler your build host, you could run the project as follows:: 15509209eecSAndrew Geissler 15609209eecSAndrew Geissler $ ./tmp/usr/local/bin/hello 15709209eecSAndrew Geissler 15809209eecSAndrew Geissler As expected, the project displays the "Hello World!" message. 15909209eecSAndrew Geissler 16009209eecSAndrew GeisslerMakefile-Based Projects 16109209eecSAndrew Geissler======================= 16209209eecSAndrew Geissler 16309209eecSAndrew GeisslerSimple Makefile-based projects use and interact with the cross-toolchain 16409209eecSAndrew Geisslerenvironment variables established when you run the cross-toolchain 16509209eecSAndrew Geisslerenvironment setup script. The environment variables are subject to 16609209eecSAndrew Geisslergeneral ``make`` rules. 16709209eecSAndrew Geissler 16809209eecSAndrew GeisslerThis section presents a simple Makefile development flow and provides an 16909209eecSAndrew Geisslerexample that lets you see how you can use cross-toolchain environment 17009209eecSAndrew Geisslervariables and Makefile variables during development. 17109209eecSAndrew Geissler 17209209eecSAndrew Geissler.. image:: figures/sdk-makefile-flow.png 17309209eecSAndrew Geissler :align: center 174d583833aSAndrew Geissler :width: 70% 17509209eecSAndrew Geissler 17609209eecSAndrew GeisslerThe main point of this section is to explain the following three cases 17709209eecSAndrew Geisslerregarding variable behavior: 17809209eecSAndrew Geissler 179615f2f11SAndrew Geissler- *Case 1 --- No Variables Set in the Makefile Map to Equivalent 18009209eecSAndrew Geissler Environment Variables Set in the SDK Setup Script:* Because matching 18109209eecSAndrew Geissler variables are not specifically set in the ``Makefile``, the variables 18209209eecSAndrew Geissler retain their values based on the environment setup script. 18309209eecSAndrew Geissler 184615f2f11SAndrew Geissler- *Case 2 --- Variables Are Set in the Makefile that Map to Equivalent 18509209eecSAndrew Geissler Environment Variables from the SDK Setup Script:* Specifically 18609209eecSAndrew Geissler setting matching variables in the ``Makefile`` during the build 18709209eecSAndrew Geissler results in the environment settings of the variables being 18809209eecSAndrew Geissler overwritten. In this case, the variables you set in the ``Makefile`` 18909209eecSAndrew Geissler are used. 19009209eecSAndrew Geissler 191615f2f11SAndrew Geissler- *Case 3 --- Variables Are Set Using the Command Line that Map to 19209209eecSAndrew Geissler Equivalent Environment Variables from the SDK Setup Script:* 19309209eecSAndrew Geissler Executing the ``Makefile`` from the command line results in the 19409209eecSAndrew Geissler environment variables being overwritten. In this case, the 19509209eecSAndrew Geissler command-line content is used. 19609209eecSAndrew Geissler 19709209eecSAndrew Geissler.. note:: 19809209eecSAndrew Geissler 19909209eecSAndrew Geissler Regardless of how you set your variables, if you use the "-e" option 200c926e17cSAndrew Geissler with ``make``, the variables from the SDK setup script take precedence:: 20109209eecSAndrew Geissler 20209209eecSAndrew Geissler $ make -e target 20309209eecSAndrew Geissler 20409209eecSAndrew Geissler 20509209eecSAndrew GeisslerThe remainder of this section presents a simple Makefile example that 20609209eecSAndrew Geisslerdemonstrates these variable behaviors. 20709209eecSAndrew Geissler 20809209eecSAndrew GeisslerIn a new shell environment variables are not established for the SDK 20909209eecSAndrew Geissleruntil you run the setup script. For example, the following commands show 21009209eecSAndrew Geisslera null value for the compiler variable (i.e. 211517393d9SAndrew Geissler:term:`CC`):: 21209209eecSAndrew Geissler 21309209eecSAndrew Geissler $ echo ${CC} 21409209eecSAndrew Geissler 21509209eecSAndrew Geissler $ 21609209eecSAndrew Geissler 21709209eecSAndrew GeisslerRunning the 21809209eecSAndrew GeisslerSDK setup script for a 64-bit build host and an i586-tuned target 21909209eecSAndrew Geisslerarchitecture for a ``core-image-sato`` image using the current &DISTRO; 22009209eecSAndrew GeisslerYocto Project release and then echoing that variable shows the value 221c926e17cSAndrew Geisslerestablished through the script:: 22209209eecSAndrew Geissler 22309209eecSAndrew Geissler $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux 22409209eecSAndrew Geissler $ echo ${CC} 22509209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/&DISTRO;/sysroots/i586-poky-linux 22609209eecSAndrew Geissler 22709209eecSAndrew GeisslerTo illustrate variable use, work through this simple "Hello World!" 22809209eecSAndrew Geisslerexample: 22909209eecSAndrew Geissler 230517393d9SAndrew Geissler#. *Create a Working Directory and Populate It:* Create a clean 23109209eecSAndrew Geissler directory for your project and then make that directory your working 232517393d9SAndrew Geissler location:: 23309209eecSAndrew Geissler 23409209eecSAndrew Geissler $ mkdir $HOME/helloworld 23509209eecSAndrew Geissler $ cd $HOME/helloworld 23609209eecSAndrew Geissler 23709209eecSAndrew Geissler After 23809209eecSAndrew Geissler setting up the directory, populate it with files needed for the flow. 23909209eecSAndrew Geissler You need a ``main.c`` file from which you call your function, a 24009209eecSAndrew Geissler ``module.h`` file to contain headers, and a ``module.c`` that defines 24109209eecSAndrew Geissler your function. 24209209eecSAndrew Geissler 24309209eecSAndrew Geissler Create the three files as follows: 24409209eecSAndrew Geissler 245c926e17cSAndrew Geissler - ``main.c``:: 24609209eecSAndrew Geissler 24709209eecSAndrew Geissler #include "module.h" 24809209eecSAndrew Geissler void sample_func(); 24909209eecSAndrew Geissler int main() 25009209eecSAndrew Geissler { 25109209eecSAndrew Geissler sample_func(); 25209209eecSAndrew Geissler return 0; 25309209eecSAndrew Geissler } 25409209eecSAndrew Geissler 255c926e17cSAndrew Geissler - ``module.h``:: 25609209eecSAndrew Geissler 25709209eecSAndrew Geissler #include <stdio.h> 25809209eecSAndrew Geissler void sample_func(); 25909209eecSAndrew Geissler 260c926e17cSAndrew Geissler - ``module.c``:: 26109209eecSAndrew Geissler 26209209eecSAndrew Geissler #include "module.h" 26309209eecSAndrew Geissler void sample_func() 26409209eecSAndrew Geissler { 26509209eecSAndrew Geissler printf("Hello World!"); 26609209eecSAndrew Geissler printf("\n"); 26709209eecSAndrew Geissler } 26809209eecSAndrew Geissler 269517393d9SAndrew Geissler#. *Source the Cross-Toolchain Environment Setup File:* As described 27009209eecSAndrew Geissler earlier in the manual, installing the cross-toolchain creates a 27109209eecSAndrew Geissler cross-toolchain environment setup script in the directory that the 27209209eecSAndrew Geissler SDK was installed. Before you can use the tools to develop your 27309209eecSAndrew Geissler project, you must source this setup script. The script begins with 27409209eecSAndrew Geissler the string "environment-setup" and contains the machine architecture, 27509209eecSAndrew Geissler which is followed by the string "poky-linux". For this example, the 27609209eecSAndrew Geissler command sources a script from the default SDK installation directory 277d1e89497SAndrew Geissler that uses the 32-bit Intel x86 Architecture and the &DISTRO_NAME; Yocto 278c926e17cSAndrew Geissler Project release:: 27909209eecSAndrew Geissler 280d1e89497SAndrew Geissler $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux 28109209eecSAndrew Geissler 28292b42cb3SPatrick Williams Another example is sourcing the environment setup directly in a Yocto 28392b42cb3SPatrick Williams build:: 28492b42cb3SPatrick Williams 28592b42cb3SPatrick Williams $ source tmp/deploy/images/qemux86-64/environment-setup-core2-64-poky-linux 28692b42cb3SPatrick Williams 287517393d9SAndrew Geissler#. *Create the Makefile:* For this example, the Makefile contains 2880903674eSAndrew Geissler two lines that can be used to set the :term:`CC` variable. One line is 28909209eecSAndrew Geissler identical to the value that is set when you run the SDK environment 2900903674eSAndrew Geissler setup script, and the other line sets :term:`CC` to "gcc", the default 291c926e17cSAndrew Geissler GNU compiler on the build host:: 29209209eecSAndrew Geissler 29309209eecSAndrew Geissler # CC=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux 29409209eecSAndrew Geissler # CC="gcc" 29509209eecSAndrew Geissler all: main.o module.o 29609209eecSAndrew Geissler ${CC} main.o module.o -o target_bin 29709209eecSAndrew Geissler main.o: main.c module.h 29809209eecSAndrew Geissler ${CC} -I . -c main.c 299*b542dec1SPatrick Williams module.o: module.c module.h 300*b542dec1SPatrick Williams ${CC} -I . -c module.c 30109209eecSAndrew Geissler clean: 30209209eecSAndrew Geissler rm -rf *.o 30309209eecSAndrew Geissler rm target_bin 30409209eecSAndrew Geissler 305517393d9SAndrew Geissler#. *Make the Project:* Use the ``make`` command to create the binary 30609209eecSAndrew Geissler output file. Because variables are commented out in the Makefile, the 3070903674eSAndrew Geissler value used for :term:`CC` is the value set when the SDK environment setup 308c926e17cSAndrew Geissler file was run:: 30909209eecSAndrew Geissler 31009209eecSAndrew Geissler $ make 31109209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c 31209209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c 31309209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin 31409209eecSAndrew Geissler 31509209eecSAndrew Geissler From the results of the previous command, you can see that 3160903674eSAndrew Geissler the compiler used was the compiler established through the :term:`CC` 31709209eecSAndrew Geissler variable defined in the setup script. 31809209eecSAndrew Geissler 3190903674eSAndrew Geissler You can override the :term:`CC` environment variable with the same 32009209eecSAndrew Geissler variable as set from the Makefile by uncommenting the line in the 321517393d9SAndrew Geissler Makefile and running ``make`` again:: 32209209eecSAndrew Geissler 32309209eecSAndrew Geissler $ make clean 32409209eecSAndrew Geissler rm -rf *.o 32509209eecSAndrew Geissler rm target_bin 32609209eecSAndrew Geissler # 32709209eecSAndrew Geissler # Edit the Makefile by uncommenting the line that sets CC to "gcc" 32809209eecSAndrew Geissler # 32909209eecSAndrew Geissler $ make 33009209eecSAndrew Geissler gcc -I . -c main.c 33109209eecSAndrew Geissler gcc -I . -c module.c 33209209eecSAndrew Geissler gcc main.o module.o -o target_bin 33309209eecSAndrew Geissler 33409209eecSAndrew Geissler As shown in the previous example, the 33509209eecSAndrew Geissler cross-toolchain compiler is not used. Rather, the default compiler is 33609209eecSAndrew Geissler used. 33709209eecSAndrew Geissler 33809209eecSAndrew Geissler This next case shows how to override a variable by providing the 33909209eecSAndrew Geissler variable as part of the command line. Go into the Makefile and 34009209eecSAndrew Geissler re-insert the comment character so that running ``make`` uses the 34109209eecSAndrew Geissler established SDK compiler. However, when you run ``make``, use a 3420903674eSAndrew Geissler command-line argument to set :term:`CC` to "gcc":: 34309209eecSAndrew Geissler 34409209eecSAndrew Geissler $ make clean 34509209eecSAndrew Geissler rm -rf *.o 34609209eecSAndrew Geissler rm target_bin 34709209eecSAndrew Geissler # 34809209eecSAndrew Geissler # Edit the Makefile to comment out the line setting CC to "gcc" 34909209eecSAndrew Geissler # 35009209eecSAndrew Geissler $ make 35109209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c 35209209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c 35309209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin 35409209eecSAndrew Geissler $ make clean 35509209eecSAndrew Geissler rm -rf *.o 35609209eecSAndrew Geissler rm target_bin 35709209eecSAndrew Geissler $ make CC="gcc" 35809209eecSAndrew Geissler gcc -I . -c main.c 35909209eecSAndrew Geissler gcc -I . -c module.c 36009209eecSAndrew Geissler gcc main.o module.o -o target_bin 36109209eecSAndrew Geissler 36209209eecSAndrew Geissler In the previous case, the command-line argument overrides the SDK 36309209eecSAndrew Geissler environment variable. 36409209eecSAndrew Geissler 36509209eecSAndrew Geissler In this last case, edit Makefile again to use the "gcc" compiler but 366c926e17cSAndrew Geissler then use the "-e" option on the ``make`` command line:: 36709209eecSAndrew Geissler 36809209eecSAndrew Geissler $ make clean 36909209eecSAndrew Geissler rm -rf *.o 37009209eecSAndrew Geissler rm target_bin 37109209eecSAndrew Geissler # 37209209eecSAndrew Geissler # Edit the Makefile to use "gcc" 37309209eecSAndrew Geissler # 37409209eecSAndrew Geissler $ make 37509209eecSAndrew Geissler gcc -I . -c main.c 37609209eecSAndrew Geissler gcc -I . -c module.c 37709209eecSAndrew Geissler gcc main.o module.o -o target_bin 37809209eecSAndrew Geissler $ make clean 37909209eecSAndrew Geissler rm -rf *.o 38009209eecSAndrew Geissler rm target_bin 38109209eecSAndrew Geissler $ make -e 38209209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c 38309209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c 38409209eecSAndrew Geissler i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin 38509209eecSAndrew Geissler 38609209eecSAndrew Geissler In the previous case, the "-e" option forces ``make`` to 38709209eecSAndrew Geissler use the SDK environment variables regardless of the values in the 38809209eecSAndrew Geissler Makefile. 38909209eecSAndrew Geissler 390517393d9SAndrew Geissler#. *Execute Your Project:* To execute the project (i.e. ``target_bin``), 391c926e17cSAndrew Geissler use the following command:: 39209209eecSAndrew Geissler 39309209eecSAndrew Geissler $ ./target_bin 39409209eecSAndrew Geissler Hello World! 39509209eecSAndrew Geissler 39609209eecSAndrew Geissler .. note:: 39709209eecSAndrew Geissler 39809209eecSAndrew Geissler If you used the cross-toolchain compiler to build 39909209eecSAndrew Geissler target_bin 40009209eecSAndrew Geissler and your build host differs in architecture from that of the 40109209eecSAndrew Geissler target machine, you need to run your project on the target device. 40209209eecSAndrew Geissler 40309209eecSAndrew Geissler As expected, the project displays the "Hello World!" message. 404