Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Building Wind River* Linux* Applications from Command Line

$
0
0

Before compiling applications for running on target Wind River* Linux* OS, you must install Wind River* Linux* 4.3 - 6.0.x and build sysroot for the target platform.

To find out more about Wind River* Linux* and how to install the required Wind River* Linux* tool-chain, go to http://www.windriver.com/products/linux/.

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. You can use this method for all versions of Wind River* Linux* 4.3 to 6.0.

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. For example, for the Wind River* Linux* platform, the prefix value, for a 32-bit target, is i586-wrs-linux-. Append a hyphen to the prefix only if the toolchain prefix ends with a hyphen.

For example, to set the environment variables for Wind River* Linux* targets, execute the following commands:

//On Linux* host
//For 32-bit target:
export PATH=<WRL6_path>/x86_64-linux/usr/bin/i586-wrs-linux:$PATH
export SYSROOT=<WRL6_path>/qemux86
export GNU_PREFIX=i586-wrs-linux-

//For 64-bit target:
export PATH=<WRL6_path>/x86_64-linux/usr/bin/x86_64-wrs-linux:$PATH
export SYSROOT=<WRL6_path>/qemux86-64
export GNU_PREFIX=x86_64-wrs-linux-

//On Windows* host
//For 32-bit target:
set PATH=C:\<WRL6_path>\x86_64-linux\usr\bin\i586-wrs-linux;%PATH%
set SYSROOT=C:\<WRL6_path>\qemux86
set GNU_PREFIX=i586-wrs-linux-

//For 64-bit target:
set PATH=C:\<WRL6_path>\x86_64-linux\usr\bin\x86_64-wrs-linux;%PATH%
set SYSROOT=C:\<WRL6_path>\qemux86-64
set GNU_PREFIX=x86_64-wrs-linux-

Use icc/icl from the command line with the –gnu-prefix and --sysroot compiler options, as follows:

icc my_source_file.c -gnu-prefix=$GNU_PREFIX --sysroot=$SYSROOT      //Linux* host

icl my_source_file.c -gnu-prefix=%GNU_PREFIX% --sysroot=%SYSROOT%    //Windows* host

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. Use this method only if you are cross-compiling for Wind River* Linux* versions 4.3 to 5.0.x.

After installation is completed and sysroot is created, set the following two environment variables to match cross-compilation tools directories for Wind River* Linux* 4.3 to 5.0.x platforms:

  • WRL_TOOLCHAIN: must contain the path to the directory inside the Wind River Linux installation tree where the tool-chain for the target platform resides.

  • WRL_SYSROOT: must contain the path to the built sysroot for the target platform.

For Wind River* Linux* 4.3 64-bit target:

//On Linux* host:
export WRL_TOOLCHAIN=<some_path>/wrl43/wrlinux-4/layers/wrll-toolchain-4.4a-341/i586/toolchain/x86-linux2
export WRL_SYSROOT=<some_path>/wrl43/intel64/export/sysroot/common_pc_64-glibc_std/sysroot

//On Windows* host:
set WRL_TOOLCHAIN=<some_path>\wrl43\wrlinux-4\layers\wrll-toolchain-4.4a-341\i586\toolchain\x86-win32
set WRL_SYSROOT=<some_path>\wrl43\intel64\export\sysroot\common_pc_64-glibc_std\sysroot

For Wind River* Linux 5.0.x 64-bit target:

//On Linux* host:
export WRL_TOOLCHAIN=<some_path>/wrl50/wrlinux-5/layers/wr-toolchain/4.6-60
export WRL_SYSROOT=<some_path>/wrl50/intel64/export/sysroot/intel-xeon-core_glibc_std/bitbake_build/tmp/sysroots/intel-xeon-core

//On Windows* host:
set WRL_TOOLCHAIN=<some_path>\wrl50\wrlinux-5\layers\wr-toolchain\4.6-60-win3
set WRL_SYSROOT=<some_path>\wrl50\intel64\export\sysroot\intel-xeon-core_glibc_std\bitbake_build\tmp\sysroots\intel-xeon-core

In the above examples, <some_path> is any path, like /export/SDK (Linux* host) or C:\ (Windows* host) and target is <ia32> or <intel64>.

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 Wind River* Linux* target, specify either -platform=wrl43 or -platform=wrl50 option depending on the target OS version.

To compile a C source file, my_source_file.c, for Wind River* Linux* 4.3 target, use a command similar to the following:

icc -platform=wrl43 my_source_file.c

To compile a C++ source file, my_source_file.cpp, for Wind River* Linux* 5.0.x target, use a command similar to the following:

icpc -platform=wrl50 my_source_file.cpp

Following successful compilation, an executable named a.out is created in the current directory. Copy a.out onto the target machine running Wind River* Linux* 4.3 or 5.0, and verify that a.out runs on the target machine.

See Also


Inglés

Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>