The Intel® C++ Compiler, also known as icc, is a high performance compiler which lets you build and optimize your C/C++ applications for the Linux* based operating system. The Intel® C++ compiler provides complete supports for various embedded Linux* system. With multiple features of Intel® C++ compiler, you can easily start to use icc for new project developing, or migrate the existing project from GNU compiler.

Embedded system development is a cross-platform development in most cases. The applications development normally needs cross-compilation which requires a host compilation system and a target embedded system. The Intel® C++ compiler fully supports cross-platform compilation as well. To develop the applications for embedded target and extract the best performance of your application, the Intel® C++ compiler is one of the best choices for IA based embedded system.

The Intel® C++ Compiler is one key component of Intel® System Studio. In this article, we will cover the following topics.

The Intel® C++ compiler supports most of major Linux distributions as the HOST operation system such as Fedora*, Ubuntu*, Redhat* etc operation systems. It also supports Windows host to Linux target cross build.

Generally speaking, to compile an application for an embedded target, we need to install or build the SDK (Software Development Kits) and the SYSROOT (target system root). The SDK normally contains various tool chains like gnu binutils, gnu cross compiler, supporting libraries and header files etc which let you use the cross gcc compiler to build your applications for target system. The SYSROOT normally contains the target system libraries and header files, the glibc libraries and header files which supporting your cross build.

The Intel® C++ compiler relies on the SDK and SYSROOT for the cross build. It needs the PATH to the gcc cross compiler to detect the folder info-structure of the gnu tool chain during the compilation. It will call gnu “ar” and “ld” for final archive and linking after the compilation. The Intel® C++ Compiler also needs the PATH to the SYSROOT so that to add the right system and glibc header files, libraries etc during the compilation.

Intel C++ Compiler supports the GCC compatible --sysroot option. We also introduced the -gnu-prefix option to support the integration with the cross build gcc toolchain. You may just use the option --gnu-prefix and the option --sysroot to support your cross build with Intel C++ compiler. For more details of this feature, please refer to compiler documentations or the article "Improved sysroot support in Intel C++ Compiler for cross compile".

Intel® C++ Compiler Run-time Libraries

If you are linking your application built with the Intel C++ Compiler dynamically, you will need to make the Intel C++ Compiler runtime libraries available on the target system. After you installed the Intel System Studio, you can find the Intel C++ Compiler runtime libraries in the Intel System Studio installation folder <ISS_INTALL_PATH>/targets. Unpack the file system_studio_target.tgz file in that folder, find the Intel C++ Compiler libraries which are located in the system_studio_target/compiler/lib directory.Copy the libraries to the system folder which can be found directly during the binary launch, or add the library path the LD_LIBRARY_PATH environment before the binary launch.

Porting from GNU Compiler to Intel® C++ Compiler

The nature of the compiler is to convert and optimize the C/C++ source program to binary. After compilation, the C/C++ source files are compiled to the object files (.o files). The linker (ld) is responsible to link all the object files together with other system libraries to the final executables. For Intel® C++ compiler, it can recognize the GNU tool chains and invoke the linker automatically after the compilation. Please note that Intel® C++ compiler does not provide its own linker. It will call the GNU linker during the linking stage. Similarly for archive, the Intel® C++ compiler will call GNU “ar” for archiving. All of these automatic things are done by Intel® compiler driver, icc, icpc, xiar and xild.

“icc” and “icpc” is the Intel® C++ compiler entry for compilation. They are used to compile the C/C++ source code to object files during compilation, or link the different binaries to one binary during linking stage by automatically calling the gnu linker.

“xiar” is the “ar” of Intel compiler. It will perform some optimizations among the multiple archive files (when possible), and then invoke the GNU “ar” automatically to archive all the files to one library.

“xild” is the “ld” of Intel compiler. It will perform the cross file optimizations and call GNU linker “ld” after that optimization.

Switching from GNU gcc compiler to Intel® C++ compiler is quite easy for your project. Consider the following tables when you porting to Intel® C++ compiler.

CC

CXX

LD

AR

GNU Compiler

gcc

g++

gcc

g++

ld

ar

Intel® C++ Compiler

icc

icpc

icc

icpc

xild

xiar

If you are using Makefile to build your application, below are the basic steps for you to make the migration from gcc to icc:

1.You may simply change the variable CC from gcc to icc, CXX from g++ to icpc, LD to icc if it is gcc, LD to icpc if it is g++, LD to xild if it is ld, AR from ar to xiar. Please note that the gcc compiler for cross build normally has a prefix in the name such as i586-poky-linux-gcc.

2.If gcc compiler has a prefix in the name, add option -gnu-prefix=<val> option to icc. The <val> is the gcc compiler prefix string. For example, -gnu-prefix=i586-poky-linux- for gcc with name i586-poky-linux-gcc. Similarly for "xiar" and "xild", use the option -qgnu-prefix=<val>.

4.If you are using “icc” or “icpc” for linking, the Intel® C++ Compiler will take care of the Intel® Compiler libraries automatically during linking stage. If you are using “ld” for linking, after you change it to “xild”, you may still need to add the Intel® C++ compiler libraries manually. For example, add option -L/opt/intel/system_studio_x.y.z/compiler/lib/<arch> to the “xild” where <arch> is the architecture “ia32” or “intel64” according to your compilation. In addition, add -lirc -limf -lsvml etc link options to “xild” so that the linker can find the right Intel® libraries when linking to the final executable. Otherwise the linker will report some Intel® library functions are not defined.

6.The next step will be adding Intel® C++ Compiler specific optimization options to the compilation flags. This is another topic which can be found in other articles. Refer to the following linker for more details:

The Intel® C++ Compiler is compatible with the GNU* compiler. Most of the GNU* common options and language extensions are supported by Intel® C++ Compiler. You can refer to the following page to get the white paper for Intel® C++ Compiler compatibility with GNU* compilers.

In addition, Intel® C++ Compiler has more restricted source code check than GNU* compilers. Some source code checking may trigger a fatal error while most of them will flag warning messages. If you are using -Werror option for your gcc build, you need to remove this option before the icc build. Otherwise you may find lots of errors which are mainly caused by the additional Intel® C++ Compiler warnings. You are highly recommended to investigate the warnings from Intel® C++ compiler so that to improve the code quality. If you are confident and don’t want the warnings, you can use the option -diag-disable <v1>[,<v2>,...] to disable the specified diagnostics or diagnostic groups where <vN> may be individual diagnostic numbers or group names.