Before compiling applications for running on target CE Linux* OS, you must install CE Linux* OS and build sysroot
for a target platform.
Using -gnu-prefix and --sysroot Compiler Options for Cross-Compiling
This method uses the --sysroot and -gnu-prefix compiler options instead of setting environment variables and using the -platform compiler option.
The --sysroot option specifies the target root directory of headers and libraries. For example, if the headers and libraries are normally located in /usr/include and /usr/lib respectively, --sysroot=/mydir causes the compiler to search in /mydir/usr/include and /mydir/usr/lib for the headers and libraries.
The -gnu-prefix option specifies a string that prepends the name of GNU tools called from the Intel® C++ Compiler. The value depends on the GNU toolchain used for a particular operating system. Append a hyphen to the prefix only if the toolchain prefix ends with a hyphen.
For example, to set the environment variables for CE* Linux* targets, execute the following commands:
export PATH=<CEL_path>/celpr28/staging_dir/bin:$PATH export SYSROOT=<CEL_path>/celpr28/i686-linux-elf export GNU_PREFIX=i686-cm-linux-
Use icc from the command line with the -gnu-prefix and --sysroot compiler options, as follows:
icc my_sourc_file.c -gnu-prefix=$GNU_PREFIX --sysroot=$SYSROOT
Following successful compilation, an executable named a.out is created in the current directory. Copy a.out onto the target machine and verify that a.out runs on the target machine.
Using -platform Compiler Option for Cross-Compiling
In this method you set specific environment variables and use the -platform option to cross-compile.
After installation is completed and sysroot
is created, set the following two environment variables to match cross-compilation tools directories:
CEL_TOOLCHAIN: must contain the path to the directory inside the CE Linux installation tree where the toolchain for the target platform resides.
CEL_SYSROOT: must contain the path to the built sysroot for the target platform.
For example:
export CEL_TOOLCHAIN=<some_path>/celpr28/staging_dir export CEL_SYSROOT=<some_path>/celpr28/i686-linux-elf //where <some_path> is any path, for example, /export/SDK.
The corresponding environment file is located in <install-dir>/bin/<target> (Linux* host) and <install-dir>\bin\<target> (Windows* host), where <install-dir> is /opt/intel/system_studio_2015.0.xyz/ and target is <ia32> or <intel64> on Linux* host, and <install-dir> is C:\Program Files (x86)\Intel\System Studio 2015.0.xyz\ on Windows* host.
Cross-compiling with -platform compiler option
Each time you compile for CE Linux* target, specify -platform=celpr28 compiler option.
To compile a C source file, for example, my_source_file.c, use a command similar to the following example:
icc -platform=celpr28 my_source_file.c
To compile a C++ source file, for example, my_source_file.cpp, use a command similar to the following example:
icpc -platform=celpr28 my_source_file.cpp
The corresponding environment file is located in <install-dir>/bin/ia32, where <install-dir>
is /opt/intel/system_studio_2015.0.xyz
Following successful compilation, an executable named a.out is created in the current directory. Copy a.out onto target machine running CE Linux* OS and verify that a.out runs on target machine.