Development Reference Guides

Contents

Create a Simple Eclipse* Project

The sections below show you how to create a simple project using Eclipse*.

Create a New Eclipse Project

To create a new Eclipse project:
  1. Select
    File
    New
    Project...
    The
    New Project
    wizard opens.
  2. Expand the
    C/C++ Project
    tab and select the appropriate project type. Click
    Next
    to continue.
  3. For
    Project name
    , enter
    hello_world
    . Deselect the
    Use default location
    to specify a directory for the new project.
  4. In the
    Project Type
    list, expand the
    Executable
    project type and select
    Hello World C++ Project
    for C++ or
    Hello World DPC++ Project
    for DPC++.
  5. In the
    Toolchains
    list, select
    Intel(R) oneAPI DPC++ Compiler
    for a DPC++ project, or the
    Intel C++ Compiler
    for a C++ project
    . Click
    Next
    .
    • If you need to see the toolchains for the compilers that are not locally installed, uncheck
      Show project types and toolchains only if they are supported on the platform
      . You are only able to view and configure these toolchains if the proper compilers are installed.
    • If you have multiple versions of the compiler installed, they appear in the project’s properties under
      C/C++ Build
      Settings
      on the
      Intel(R) oneAPI DPC++ Compiler
      tab for a DPC++ project, or the
      Intel C++ Compiler
      tab for a C++ project
      .
  6. The
    Basic Settings
    page allows specifying template information, including
    Author
    and
    Copyright notice
    , which appear as a comment at the top of the generated source file. After entering desired fields, click
    Next
    .
  7. The
    Select Configurations
    page allows specifying deployment platforms and configurations. By default, a
    Debug
    and
    Release
    configuration is created for the selected toolchain. Select no (
    Deselect all
    ), multiple, or all (
    Select all
    ) configurations. To edit project properties, click the
    Advanced settings
    button. Click
    Finish
    to create the
    hello_world
    project.
    Configurations can be created after the project is created by selecting
    Project
    Properties
    .
  8. If the view is not the
    C/C++ Development Perspective
    (default), an
    Open Associated Perspective
    dialog box opens. In the
    C/C++ Perspective
    , click
    Yes
    to proceed.
An entry for your
hello_world
project appears in the
Project Explorer
view.

Add a C Source File

To add a source file to the
hello_world
project:
  1. Select the
    hello_world
    project in the
    Project Explorer
    view.
  2. Select
    File
    New
    Source File
    . The
    New Source File
    dialog box opens.
    The dialog box automatically populates the source folder for the source file to be created. You can change this by entering a new location or selecting
    Browse
    .
  3. Enter
    new_source_file.c
    in the
    Source File
    field.
  4. Select a
    Template
    from the drop-down list or
    Configure
    a new template.
  5. Click
    Finish
    to add the file to the
    hello_world
    project.
  6. In the
    Editor
    view, add your code for
    new_source_file.c
    .
  7. When your code is complete,
    Save
    your file.

Set Options for a Project or File

You can specify compiler, linker, and archiver options at the project and source file level. Follow these steps to set options for a project or file:
  1. Right-click a project or source file in the
    Project Explorer
    .
  2. Select
    Properties
    . The property pages dialog box opens.
  3. Select
    C/C++ Build
    >
    Settings
    .
  4. Select the
    Tool Settings
    tab and click an option category for
    Intel C Compiler
    ,
    Intel C++ Compiler
    , or
    Intel C++ Linker
    for a C++ project, or select
    Intel® oneAPI DPC++ Compiler
    or
    Intel® oneAPI DPC++ Linker
    for a DPC+++ project.
  5. Set the options to apply to the project or file.
    • Some properties use check boxes, drop-down boxes, or dialog boxes to specify compiler options. For a description on options properties, hover over the option to display a tooltip. After setting the desired options in command line syntax, select
      Apply
      .
    • To specify an option that is not available from the
      Properties
      dialog, use
      C/C++ Build Settings
      >
      Settings
      >
      <Compiler>
      >
      Command Line
      . The Compiler entry has one of the following values: or Intel® oneAPI DPC++ Compiler. Enter the command line options in the
      Additional Options
      field using command-line syntax and select
      Apply
      .
    • You can specify option settings for one or more configurations by using the
      Configuration
      drop-down menu.
  6. Click
    Apply and Close
    .
The compiler applies the selected options, using the selected configurations, when building. To restore default settings to all properties for the selected configuration, click the
Restore Defaults
button on any property page.

Exclude Source Files from a Build

To exclude a source file from a build:
  1. Right-click a file or folder in the
    Project Explorer
    .
  2. Select
    Resource Configurations
    >
    Exclude from build
    . The
    Exclude from build
    dialog box opens.
  3. Select one or more build configurations to exclude the file or folder from.
  4. Click
    OK
    .
The compiler excludes that file or folder when it builds using the selected project configuration.

Build a Project

To build your project:
  1. Select the
    hello_world
    project in the
    Project Explorer
    view.
  2. Select
    Project
    Build Project
    .
See the
Build
results in the
Console
view.
For a C/C++ project, use:
**** Build of configuration Debug for project hello_world **** make all Building file: ../src/hello_world.cpp Invoking: Intel C++ Compiler icpx -g -O0 -MMD -MP -MF"src/hello_world.d" -MT"src/hello_world.d" -c -o "src/hello_world.o" "../src/hello_world.cpp" Finished building: ../src/hello_world.cpp Building target: hello_world Invoking: Intel C++ Linker icpx -O0 -o "hello_world" ./src/hello_world.o Finished building target: hello_world Build Finished. 0 errors, 0 warnings.
For a DPC++ project, use:
**** Build of configuration Debug for project DPCPPhelloworld **** make all Building file: ../main.cpp Invoking: Intel(R) oneAPI DPC++ Compiler dpcpp -g -Wall -O0 -I/home/sys_idebuilder/eclipse-workspace/DPCPPhelloworld -MMD -MP -c -o "main.o" "../main.cpp" Finished building: ../main.cpp Building target: DPCPPhelloworld Invoking: Linker dpcpp -o "DPCPPhelloworld" ./main.o -lsycl -lOpenCL Finished building target: DPCPPhelloworld Build Finished. 0 errors, 0 warnings.
Detailed descriptions of errors, warnings, and other output can be viewed by selecting the
Problems
tab.

Run a Project

After building a project, you can run your project by following these steps:
  1. Select the
    hello_world
    project in the
    Project Explorer
    view.
  2. Select
    Run As
    Local C/C++ Application
    .
When the executable runs, the output appears in the
Console
view.

Error Parser

The Error Parser (selected by default) lets you track compile-time errors in Eclipse. To confirm that the Error Parser is active:
  1. Select the
    hello_world
    project in the
    Project Explorer
    view.
  2. Select
    Project
    Properties
    .
  3. In the
    Properties
    dialog box, select
    C/C++ Build
    Settings
    .
  4. Click the
    Error Parsers
    tab. Make sure that
    Intel C++ Error Parser
    is checked, and
    CDT Visual C Error Parser
    or
    Microsoft Visual C Error Parser
    are not checked.
  5. Click
    OK
    to update your choices, if you have changed any settings.

Use the Error Parser

The Error Parser automatically detects and manages the diagnostics generated by the
Intel® oneAPI
DPC++/C++
Compiler
.
If an error occurring in the
hello_world.c
program is compiled, for example,
#include <xstdio.h>
, the error is reported in the
Problems
view next to an error marker.
You can double-click on each error in the
Problems
view to highlight the source line, which causes the error in the
Editor
view.
Correct the error, then rebuild your project.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.