0% found this document useful (0 votes)
50 views

Using Intel C++ Compiler 8.0 With Eclipse IDE On Linux

This whitepaper describes how to use the Intel C++ Compiler within the Eclipse integrated development environment on Linux systems. It provides instructions for creating a simple "Hello World" program in Eclipse and compiling it using Intel C++. It also explains how to import and build a more complex open-source application, MySQL, in Eclipse using Intel C++. The whitepaper demonstrates configuring Eclipse to take advantage of advanced optimization options in Intel C++ and debugging applications in the Eclipse debugger.

Uploaded by

laertepalves
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Using Intel C++ Compiler 8.0 With Eclipse IDE On Linux

This whitepaper describes how to use the Intel C++ Compiler within the Eclipse integrated development environment on Linux systems. It provides instructions for creating a simple "Hello World" program in Eclipse and compiling it using Intel C++. It also explains how to import and build a more complex open-source application, MySQL, in Eclipse using Intel C++. The whitepaper demonstrates configuring Eclipse to take advantage of advanced optimization options in Intel C++ and debugging applications in the Eclipse debugger.

Uploaded by

laertepalves
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

WHITEPAPER

Using Intel® C++ Compiler 8.0


with the Eclipse Integrated Development
Environment on Linux* Systems
Introduction
This is a “how-to” guide for using Intel® C++ Compiler in
the Eclipse integrated development environment (IDE),
version 1.2, with its companion C/C++ Development
Tools (CDT), version 1.1, on the Linux* platform. For
those reading from printed copy, all links in this paper
on the Intel C++ Compiler1, Eclipse2, and the CDT3
are presented in the Additional Information and Links
section at the end of this paper.

The Eclipse Project4 is an open-source software


development project dedicated to providing a robust,
full-featured, commercial-quality, industry platform for
the development of highly integrated software tools.
It provides a core framework and set of services that
support a variety of plug-ins. CDT is one such plug-in,
providing a number of integrated development tools
that specifically support C/C++ development.

This guide assumes that you have correctly installed


Eclipse, CDT plug-ins, and Intel C++ Compiler on a
supported Linux platform. If you have not yet installed
them, please refer to the Intel® C++ Compiler 8.0 for
Linux* Getting Started Guide and to the CDT Users
FAQ for the Eclipse CDT5 for additional information.

For brevity, this paper refers to the combination of the


Eclipse and its companion CDT as the Eclipse IDE.

2
A Simple HelloWorld* Program Figure 1. Eclipse Platform with CDT Plug-In Startup
Window
This section explains how to configure the Eclipse
IDE to use Intel C++ Compiler for building a simple
HelloWorld* program. Before starting Eclipse, make
sure that the appropriate environment variables are set
for the Eclipse IDE.

Example:
export PATH=${PATH}:/usr/local/j2sdk1.4.1_02/bin
export ANT_HOME=~/ant/
export JAVA_HOME=/usr/local/j2sdk1.4.1_02

Additionally, environment variables used by the compiler


can be set easily with the following script:
. /opt/intel/compiler80/ia32/bin/iccvars.sh

Figure 1 displays a screen capture of the main Figure 2. Eclipse IDE C++ Development Perspective
workbench window that appears on your desktop when
you first start Eclipse with the CDT plug-ins installed.
The Navigator panel at the top left shows the files in
the user’s workspace. The Outline panel at the bottom
left shows a content outline of the file being edited. The
Tasks panel at the bottom right shows a list of to-dos.
The Welcome panel at the top right displays an editor
with the CDT.

To select the C/C++ Perspective, select the Window


menu then select Perspective and then C++
Development. Figure 2 shows the Eclipse IDE C/C++
Development Perspective.

To create a new C++ project, go to the File menu, then


Figure 3. Eclipse IDE Editor Showing HelloWorld
New > Project, then Standard Make C++ Project,
C++ Syntax
click Next, type HelloWorld for the project name, and
then click Finish.

To add files to this project, right-click HelloWorld,


select the File menu, then New, and then File. Select
C++ File and name it hello.cpp. Figure 3 illustrates
how to use the Eclipse IDE editor to add content to the
hello.cpp file.

3
Figure 4. HelloWorld Makefile The CDT build process executes the make command,
by default, to build projects. Therefore, you need
to create a Makefile to specify rules to build the
HelloWorld project. Figure 4 presents the Makefile for
the HelloWorld project.

Note that, in Figure 4, the CXX variable is set to icpc,


which allows the use of Intel C++ Compiler.

To build this project, select the Project menu then


select Build Project. This command compiles
hello.cpp, and creates an executable file in the current
workspace. To execute this program, select the Run
menu and then select Run As >C Local application
> hello. Figure 5 shows the output of your HelloWorld
project in the Console panel in the lower right portion of
Figure 5. Console Panel Displays the Results of the screen.
Running HelloWorld

4
Building a More Complex Figure 6. Importing Files Into a Project Through the
Import Feature of Eclipse IDE
Application from the
Eclipse IDE
MySQL is a representative, complex, open-source
application. It has a configure script to configure
the build for a particular platform and to generate
appropriate Makefiles using Makefile.in files.

To build MySQL using the Intel C++ Compiler through


the Eclipse IDE, you need to extract the MySQL source
code in some directory and make the new project point
to this location as follows:
• Create a new project, as explained for the
HelloWorld project and name it mysql.
• Add files to this project. Select the File menu,
then select Import and then File system.

Figure 6 shows the File system import process of the


Eclipse IDE. Figure 7. The mysql Directory Structure in the C++
Projects Panel
Browse the File system folder and select the mysql
directory. Figure 7 shows the directory structure in your
C/C++ Projects panel on the left of the screen.

As mentioned, Makefile is required to build projects.


Generate a Makefile for the mysql project using this
configure script:

• Export environment variables to set compiler and


command line options:
export CC=icc CXX=icpc CFLAGS=-O2 CXXFLAGS=-O2

• Configure the makefile to use the Intel C++


compiler:
./configure --prefix=~/mysql_install Figure 8. Eclipse-Generated Makefile for mysql
Project and the Output of the make Command
You cannot export variables through the Eclipse
IDE. You must execute this script from the command
prompt.

To build the mysql project, select the Project menu and


then click Build Project. Figure 8 shows the generated
Makefile and the output of the make command in the
C-Build panel on the lower-right portion of the screen.

5
Figure 9. Results from Building a Test Project Using Advanced Optimization
with Intel® C++ Compiler Using the Vectorization
Option, -axW
Options of Intel® Compilers
Intel C++ Compiler provides advanced optimization
options to improve application performance on the
latest Intel processors. Some of the optimization
options include:
• -ax{M|K|W|B|P}: This option enables the
vectorizer and generates specialized and generic
32-bit code. The generic code is usually slower
than the specialized code.
• -x{M|K|W|B|P}: This option turns on the vectorizer
and generates processor-specific, specialized
code.
• -ipo: This option enables interprocedural
optimizations.

For more details, refer to the white paper, Optimizing


Figure 10. Eclipse IDE Debug Perspective
Applications with the Intel® C++ and Fortran Compilers
for Windows* and Linux*6.

Intel C++ Compiler vectorizes the loops in vector.cpp


and prints the summary of optimizations. Figure 9
is a screen capture of the main workbench window
that appears when you build a test project using the
vectorization option, -axW.

Debugging Applications
This section explains how to debug an application with
gdb as supported in the Eclipse IDE. The example
assumes that vector.cpp is built with the –g option.

To debug this project, select the Run menu, then select


Figure 11. Eclipse IDE Debug Perspective Run Debug As, and then C local application. Select
Menu Debugging Options vector executable and gdb as a debug configuration to
debug. Figure 10 shows how this process automatically
starts Debug Perspective.

Figure 11 demonstrates the Run menu in the Eclipse


IDE Debug Perspective. Run offers a variety of options
to aid in debugging including Add Watchpoint, Add/
Remove Breakpoint, and other debugging options.

6
Conclusion Getting Started Guide for Intel C++ Compilers:
Windows:
There are many ways of integrating your C++ projects www.intel.com/software/products/compilers/
with the Eclipse IDE. This paper has presented one techtopics/gettingstarted.pdf
such approach with the help of the Intel C++ Compiler, Linux:
presented how to import projects, and provided an www.intel.com/software/products/compilers/
overview of how to build and debug projects. While this techtopics/C_Getting_Started_Guide1.htm
document focuses on the Intel C++ compiler, a similar
approach can be used with the Intel® Fortran Compiler. Intel C++ Compiler User’s Guide:
Windows:
Additional Information and www.intel.com/software/products/compilers/cwin/
docs/ccug.htm
Links Linux:
Support for Intel® Software Development Products, www.intel.com/software/products/compilers/clin/docs/
including Intel C++ Compiler 8.0: ug/index.htm
http://premier.intel.com
Optimizing Applications with Intel C++ and Fortran
Intel Software Development Products information, Compilers for Windows and Linux:
including purchase and availability information: www.intel.com/software/products/compilers/
www.intel.com/software/products techtopics/compiler_optimization.pdf

Intel® Compilers: Eclipse Organization:


www.intel.com/software/products/compilers www.eclipse.org

Release Notes for Intel C++ Compilers: Eclipse CDT (C++ development tools):
Windows: www.eclipse.org/cdt/
www.intel.com/software/products/compilers/cwin/
relnotes.pdf Eclipse Project Home Page:
Linux: www.eclipse.org/eclipse/index.html
www.intel.com/software/products/compilers/clin/
relnotes.pdf Eclipse Project FAQ:
www.eclipse.org/eclipse/faq/eclipse-faq.html

Eclipse CDT FAQ:


dev.eclipse.org/viewcvs/index.cgi/~checkout~/cdt-
home/user/faq.html?cvsroot=Tools_Project

1
See www.intel.com/software/products/compilers
2
See www.eclipse.org
3
See www.eclipse.org/cdt
4
See www.eclipse.org/eclipse/index.html
5
See dev.eclipse.org/viewcvs/index.cgi/~checkout~/cdt-home/user/faq.html?cvsroot=Tools_Project
6
See www.intel.com/software/products/compilers/techtopics/compiler_optimization.pdf
7
Intel Corporation
2200 Mission College Blvd.
Santa Clara, CA 95052-8119
USA

For product and purchase information visit:


www.intel.com/software/products

Intel, the Intel Logo, Itanium, Pentium, Intel Xeon, Intel XScale and VTune are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and
other countries.

*Other names and brands may be claimed as the property of others.

INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE,
TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL’S TERMS AND CONDITIONS OF SALE FOR SUCH
PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL
PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT,
COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. Intel products are not intended for use in medical, life saving, life sustaining applications. Intel may make changes
to specifications and product descriptions at any time, without notice.

Copyright © 2004, Intel Corporation. All Rights Reserved. 0104/JXP/ITF/PDF 300349-001

You might also like