You can use the Intel® C++ Compiler 15.0 to develop 32-bit and 64-bit applications for Intel® architecture-based devices.
This guide refers to the Intel® C++ Compiler as the compiler, or icc.
Android Targets
Just about anything you can do in your gcc source code for your Android applications, you can also do with the Intel C++ Compiler. You can even build applications that use gcc for devices based on ARM* Architecture and the Intel compiler for devices based on Intel® architecture. The Intel compiler is highly compatible with gcc and tools in the NDK and SDK, while delivering outstanding application performance.
The Intel C++ Compiler requires the Android NDK, which is installed as part of the Intel® INDE installation.
The Android NDK ships with sample applications that can be found in the samples
directory under the installed Android NDK directory. This guide shows how to start building for an Android* target using the hello-jni
sample application shipped with the Android NDK.
Prerequisites
Set up the Intel compiler environment for 32-bit targets with the following command:
"<compiler-install_dir>\bin\compilervars.bat ia32"
ia32
sets up the environment for 32-bit targets. Use intel64
for 64-bit targets.
For details on compilervars, refer to Using compilervars File in the User and Reference Guide for the Intel® C++ Compiler 15.0.
Using the Compiler with Eclipse*
This section explains how to configure Eclipse and Eclipse projects to use and build with icc. When you select the option to use the Eclipse integration during installation, Intel® INDE installs all necessary software, including the Android Developer Kit (ADT) and the Android NDK. The ADT includes SDK components and a version of the Eclipse IDE with built-in Android Developer Tools. For more information on ADT, see http://developer.android.com/tools/help/adt.html
.
Start Eclipse from Start> Intel® INDE> Eclipse for Android ADT .
Configure Eclipse to use the NDK plugin. Select Window> Preferences .
In the Preferences window, select Android> NDK . Enter the NDK path in the NDK Location text box and click OK.
Create a new project from the NDK samples. Select File> New> Project… . The New Project dialog box appears.
Select Android Project from Existing Code and click Next.
The Import Project window opens.
Browse to hello-jni in the NDK samples directory. The default installation path is
C:\Intel\INDE\IDEintegration\NDK\samples\hello-jni
. Confirm the project you want to load, check Copy projects into workspace, and then click Finish.The newly created project opens in the Project Explorer.
Configure the project to include Native Support, which adds Java and C/C++ support:
Right-click on the project name in the Project Explorer window and select Android Tools> Add native Support... .
A dialog opens asking for the Library Name. Set the library name to hello-jni and click Finish.
Create a new file named
Application.mk
in thejni
folder with the following lines:For 32-bit targets:
APP_ABI:=x86 NDK_TOOLCHAIN:=x86-icc
For 64-bit targets:
APP_ABI:=x86_64 NDK_TOOLCHAIN:=x86_64-icc
To build your project, right-click on the project name in the Project Explorer and select Build Project.
You can test the application on any Intel architecture-based Android device including an Android Virtual Device.
Using the Compiler with vs-android in Visual Studio*
The Intel® product installation integrates the Intel® compiler with vs-android, so you can use Visual Studio* to build your Android applications immediately.
Create a Visual C++ project, or open an existing project.
In Solution Explorer, select a project to build with the Intel® C++ Compiler.
Select Project> Properties to open the Property Pages.
Select Configuration Properties> General . Under Platform Toolset, select one of the available x86 icc toolchains.
Notice that the list of available toolsets contains a corresponding toolset for each installed Intel® C++ Compiler.
Under the Project Defaults property list, change Target Architecture to x86 Architecture (x86).
Click OK to save and close the Property Pages.
Selecting this toolset ensures that Intel® C++ Compiler is used for building your projects. Check the display of Intel-specific property pages and properties.
You can now proceed to use the Intel® Compiler to build Android* applications with Microsoft Visual Studio*. For details, check Visual Studio* documentation on www.microsoft.com.
Using the Command Line
You can build applications for Intel architecture-based Android devices in two ways. You can enable the icc toolchain with the Android NDK build system or you can use the icc toolchain as a standalone compiler. The following sections provide general guidelines for each method.
When you install the Intel® C++ Compiler, the installation program integrates the compiler into the Android NDK build system automatically. icc is the default compiler for Intel architecture-based targets for NDK revisions 9, 9b, 9c and 9d.
The Android NDK ships with sample applications that can be found in the samples directory in the Android NDK installation directory.
Using the icc toolchain with the Android NDK Build System
Use the hello-jni sample application that ships with the Android NDK. The default installation path is C:\Intel\INDE\IDEintegration\NDK\samples\hello-jni
.
Use the command-line to navigate to the jni
folder in the sample and enter one of the following commands:
For 32-bit targets:
>>$NDK_DIR/ndk-build APP_ABI=x86 NDK_TOOLCHAIN:=x86-icc
For 64-bit targets:
>>$NDK_DIR/ndk-build APP_ABI=x86_64 NDK_TOOLCHAIN:=x86_64-icc
You can specify compiler options in jni/Android.mk
. For example:
-ipo -O3 -no-prec-div
For details on compiler options, refer to Compiler Options in the User and Reference Guide for the Intel® C++ Compiler 15.0.
Using the icc toolchain as a Standalone Compiler
You can now use icc to compile C source code and icpc to compile C++ source code. For example:
>>cd %NDK_DIR%\samples\hello-jni\jni>>icc -c hello-jni.c>>icc -shared -o libhello-jni.so hello-jni.o
Building an Application for Release
By default, the NDK is configured to build an application for debugging, and all optimizations are turned off within Eclipse*. When you are ready to deploy, compile it for performance:
Open the file
Application.mk
.To switch to the release mode, add the following line:
APP_OPTIM:=release
To target a specific processor, for example, to build application to run on the Intel® Atom™ processor, add the following line:
APP_CFLAGS:=-xATOM_SSSE3
To enable advanced optimizations, such as increasing the optimization level, add the following line:
APP_CFLAGS:=-xATOM_SSSE3 -O3
To enable interprocedural optimizations, add:
APP_CFLAGS:=-xATOM_SSSE3 -O3 -ipo
Build the application.
You can pass APP_OPTIM
and APP_CFLAGS
as arguments when building from the command line. For example:
%NDK_DIR%\ndk-build V=1 -B APP_ABI=x86 NDK_TOOLCHAIN:=x86-icc APP_OPTIM=release APP_CFLAGS="-xATOM_SSSE3 -O3 -ipo"
For details, refer to High-Level Optimizations (HLO) and Interprocedural Optimization (IPO) in the User and Reference Guide for the Intel® C++ Compiler 15.0.
Documentation and Resources
Document | Description |
---|---|
Information on the product installation, new and changed features, and issues that are not described in the product documentation. | |
User and Reference Guide for the Intel® C++ Compiler 15.0 for Intel® INDE 2015 | Information specific to this product. |
How to compile and optimize your application by using optimization tools and other libraries. | |
Samples installed with the product | Learn specific compiler optimizations, features, tools, and programming concepts. |
NDK documentation | Detailed information on the Android NDK. Located in the NDK installation folder under |
Using Intel® C++ Compiler for Android* in the Microsoft* Visual Studio* | How to build Android-targeted applications in the Microsoft* Visual Studio* IDE. |
Using Advanced Intel® C++ Compiler Features for Android* Applications | How to use Intel® Cilk™ Plus Runtime on Android* to multithread your application and how to use Profile-guided Optimization (PGO) to Improve Android* OS Application Performance. |
Building Native Android* Apps Using Intel(R) C++ Compiler in Android Studio* | For the current status of Android Studio support. Android Studio support is a preview feature. |
Visit the Intel® Developer Zone | Information about Intel® C++ Compiler for Android*. |