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:
- SelectTheNew Projectwizard opens.
- Expand theC/C++ Projecttab and select the appropriate project type. ClickNextto continue.
- ForProject name, enterhello_world. Deselect theUse default locationto specify a directory for the new project.
- In theProject Typelist, expand theExecutableproject type and selectHello World C++ Projectfor C++ orHello World DPC++ Projectfor DPC++.
- In theToolchainslist, select. ClickIntel(R) oneAPI DPC++ Compilerfor a DPC++ project, or theIntel C++ Compilerfor a C++ projectNext.
- If you need to see the toolchains for the compilers that are not locally installed, uncheckShow 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 underon the.Intel(R) oneAPI DPC++ Compilertab for a DPC++ project, or theIntel C++ Compilertab for a C++ project
- TheBasic Settingspage allows specifying template information, includingAuthorandCopyright notice, which appear as a comment at the top of the generated source file. After entering desired fields, clickNext.
- TheSelect Configurationspage allows specifying deployment platforms and configurations. By default, aDebugandReleaseconfiguration is created for the selected toolchain. Select no (Deselect all), multiple, or all (Select all) configurations. To edit project properties, click theAdvanced settingsbutton. ClickFinishto create thehello_worldproject.Configurations can be created after the project is created by selecting.
- If the view is not theC/C++ Development Perspective(default), anOpen Associated Perspectivedialog box opens. In theC/C++ Perspective, clickYesto 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:
- Select thehello_worldproject in theProject Explorerview.
- Select. TheNew Source Filedialog 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 selectingBrowse.
- Enternew_source_file.cin theSource Filefield.
- Select aTemplatefrom the drop-down list orConfigurea new template.
- ClickFinishto add the file to thehello_worldproject.
- In theEditorview, add your code fornew_source_file.c.
- When your code is complete,Saveyour 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:
- Right-click a project or source file in theProject Explorer.
- SelectProperties. The property pages dialog box opens.
- SelectC/C++ Build>Settings.
- Select theTool Settingstab and click an option category forIntel C Compiler,Intel C++ Compiler, orIntel C++ Linkerfor a C++ project, or selectIntel® oneAPI DPC++ CompilerorIntel® oneAPI DPC++ Linkerfor a DPC+++ project.
- 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, selectApply.
- To specify an option that is not available from thePropertiesdialog, useC/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 theAdditional Optionsfield using command-line syntax and selectApply.
- You can specify option settings for one or more configurations by using theConfigurationdrop-down menu.
- ClickApply 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:
- Right-click a file or folder in theProject Explorer.
- SelectResource Configurations>Exclude from build. TheExclude from builddialog box opens.
- Select one or more build configurations to exclude the file or folder from.
- ClickOK.
The compiler excludes that file or folder when it builds using the selected project configuration.
Build a Project
To build your project:
- Select thehello_worldproject in theProject Explorerview.
- Select.
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:
- Select thehello_worldproject in theProject Explorerview.
- Select.
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:
- Select thehello_worldproject in theProject Explorerview.
- Select.
- In thePropertiesdialog box, select .
- Click theError Parserstab. Make sure thatIntel C++ Error Parseris checked, andCDT Visual C Error ParserorMicrosoft Visual C Error Parserare not checked.
- ClickOKto 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++
CompilerIf 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.