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

Intel® System Studio 2015: Getting Started with the Compiler for Linux* and Android* Targets

$
0
0

Overview (Android Targets)

You can use the Intel® C++ Compiler 15.0 to develop 32-bit and 64-bit applications for Intel® architecture-based devices that use Android* OS. The Intel C++ Compiler requires the Android NDK.

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 Android NDK ships with sample applications that can be found in thesamples directory under the installed Android NDK directory. This guide shows how to start building for an Android* target using thehello-jni sample application shipped with the Android NDK.

This guide refers to the Intel® C++ Compiler as the compiler, oricc.

Using the Compiler with Eclipse* (Android Targets)

This section explains how to configure Eclipse and Eclipse projects to use and build with icc. The ADT includes SDK components and a version of the Eclipse IDE with built-in Android Developer Tools. For more information on ADT, seehttp://developer.android.com/tools/help/adt.html.

If you install Intel® System Studio after installing the Android NDK, the Android NDK is integrated automatically. If you install the NDK after installing Intel® System Studio, run the integration script ndk_integration.sh (Linux hosts) orndk_integration.cmd (Windows hosts),  at <install_directory>/toolchains.

  1. Configure Eclipse to use the NDK plugin. SelectWindow> Preferences .

  2. In thePreferences window, selectAndroid> NDK . Enter the NDK path in theNDK Location text box and clickOK.

  3. Create a new project from the NDK samples. SelectFile> New> Project… . TheNew Project dialog box appears.

  4. SelectAndroid Project from Existing Code and clickNext.

    TheImport Project window opens.

  5. Browse to hello-jni in the NDK samples directory. Confirm the project you want to load, checkCopy projects into workspace, and then clickFinish.

    The newly created project opens in theProject Explorer.

  6. Configure the project to include Native Support, which adds Java and C/C++ support:

    1. Right-click on the project name in theProject Explorer window and selectAndroid Tools> Add native Support... .

    2. A dialog opens asking for the Library Name. Set the library name to hello-jni and clickFinish.

  7. Create a new file namedApplication.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
  8. To build your project, right-click on the project name in theProject Explorer and selectBuild Project.

You can test the application on any Intel architecture-based Android device including an Android Virtual Device.

Start from Visual Studio* Using vs-android

The Intel® product installation integrates the Intel® compiler with vs-android, so you can use Visual Studio* to build your Android applications immediately.

If you installed the vs-android plugin after installing Intel® System Studio, see Microsoft* Visual Studio*: vs-android Enabling for Android* Targets in theUser and Reference Guide for the Intel® C++ Compiler for information on adding the vs-android integration.

  1. Create a Visual C++ project, or open an existing project.

  2. InSolution Explorer, select a project to build with the Intel® C++ Compiler.

  3. SelectProject> Properties to open theProperty Pages.

  4. SelectConfiguration Properties> General . UnderPlatform Toolset, select one of the availablex86 icc toolchains.

    Notice that the list of available toolsets contains a corresponding toolset for each installed Intel® C++ Compiler.

  5. Under theProject Defaults property list, changeTarget Architecture tox86 Architecture (x86).

  6. ClickOK 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 (Android Targets)

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.

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 isC:\Intel\INDE\IDEintegration\NDK\samples\hello-jni.

Use the command-line to navigate to thejni 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 injni/Android.mk. For example:

-ipo -O3 -no-prec-div

For details on compiler options, refer toCompiler Options in theUser and Reference Guide for the Intel® C++ Compiler.

Using the icc toolchain as a Standalone Compiler

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. Useintel64 for 64-bit targets.

For details on compilervars, refer toUsing compilervars File in theUser and Reference Guide for the Intel® C++ 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

Overview (Linux Targets)

The following table, gives a quick summary of all the target OS environment variables and the corresponding values to be used with the-platform compiler option. This information applies to Eclipse and the command line.

Notice that for Yocto Project* 1.4 or later, or for Window River* Linux* 6 or later, you need to use a different method. For more information, seeBuilding Applications for the Yocto* Project Target orBuilding Wind River* Linux* Applications from Command Line in theUser and Reference Guide for the Intel® C++ Compiler.

Target OS

Environment Variables

-platform Compiler Option Values

CE Linux*

CEL_SYSROOT

CEL_TOOLCHAIN

celpr28

Wind River* Linux* 5

WRL_SYSROOT

WRL_TOOLCHAIN

wrl50

Yocto Project* 1.2

YL_SYSROOT

YL_TOOLCHAIN

yl12 (version 1.2)

Yocto Project* 1.3

YL_SYSROOT

YL_TOOLCHAIN

yl13

Using the Compiler with Eclipse* (Linux* Targets)

The Intel® System Studio installation automatically integrates the Intel® C++ Compiler into a preexisting Eclipse* CDT installation. If you install Eclipse after Intel® System Studio, you can integrate the compiler using Help> Install New Software in Eclipse. For more information, seeAdding the Compiler to Eclipse in theUser and Reference Guide for the Intel® C++ Compiler.

For information on which versions of Eclipse are supported refer to the Intel® System Studio Release Notes.

Follow these steps to select an existing environment file to be used with the active configuration of a current project:

  1. In Eclipse, select a project in theProject Explorer.

  2. SelectIntel Tools> Intel® System Studio Tools Environment File> Select File for <project name>. TheSelect an Environment File dialog opens.

  3. UseBrowse to locate the appropriate environment file. You can find preconfigured ones in<install_directory>\bin\ia32.

  4. SelectApply to All Configurations to use the file for all configurations in the current project.

  5. ClickOK to close the dialog.

  6. SelectProject> Build Project.

For detailed information on using the compiler with Eclipse, seeUsing Eclipse in theUser and Reference Guide for the Intel® C++ Compiler.

Using the Command Line (Linux* Targets)

The icc command invokes the C compiler. The icpc command invokes the C++ compiler.

Use the-platform compiler option, or alternatively, use the--sysroot and-gnu-prefix compiler options together. The information here describes how to use the-platform option

  1. Open a command-line window.

  2. Runcompilervars.sh (Linux hosts) orcompilervars.bat (Windows hosts) to set environment variables that define the location of compiler-related components. SeeUsing compilervars File in theUser and Reference Guide for the Intel® C++ Compiler for more information.

  3. Set the environment variables shown above, according to the target. For example:

    export YL_TOOLCHAIN=/opt/poky/1.3/sysroots/i686-pokysdk-linux/usr/bin export
    YL_SYSROOT=/opt/poky/1.3/sysroots/i586-poky-linux

    For detailed information on values to use for these variables, and for information on compiling by using the--sysroot and-gnu-prefix compiler options, seeTarget Platform Build Instructions in theUser and Reference Guide for the Intel® C++ Compiler. For Tizen targets, you must use the--sysroot and-gnu-prefix compiler options together.

  4. To compilemy_source_file.c enter:

    icc -platform=<platform_value> my_source_file.c

    For example, to compile for Yocto 1.3, enter:

    icc -platform=yl13 my_source_file.c

Englisch

Viewing all articles
Browse latest Browse all 1665

Latest Images

Trending Articles



Latest Images

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