You are on page 1of 12

Getting Started with C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition

Publish Date: Apr 28, 2015


Table of Contents

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Overview
Installation
Configuring C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition, for First Use
Creating a C/C++ Project
Creating a Build of a C/C++ Project
Configuring a Remote System
Running a C/C++ Executable on Your NI Linux Real-Time Target
Debugging a C/C++ Project
Related Information
Legal Information

Getting Started with C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition
1. Overview

The Getting Started content is provided below, and it also installs with the product in the \<National
Instruments>\Eclipse\help directory. To view larger images, extract the files from the compressed folder attached to this
page, or view the Getting Started content installed with the product.
This tutorial outlines how to create C/C++ projects using C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition, build
an executable from your project source code, and run and debug the executable on your NI Linux Real-Time target.
2. Installation

1. Install Java (Java SE 6 or greater is recommended), which you can download at http://www.java.com/getjava (
http://www.java.com/getjava).
2. Install C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition.
3. Configuring C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition, for First Use

Complete the following steps to configure C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition, for first use:
1. Launch C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition.
2. When prompted, select a folder in which to store Eclipse projects and click OK.
Tip Enable Use this as the default and do not ask again to save a project folder as your default workspace.

3. In the Eclipse welcome screen, select the Workbench icon on the far right to open the workbench view.
4. C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition, highlights the active perspective on the perspectives bar, as
shown in the following image. The first time you use C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition, the
workbench view opens in the C/C++ perspective.

1/12

www.ni.com

In the next section of this tutorial, you create a new project in the C/C++ perspective.

4. Creating a C/C++ Project

Complete the following steps to create a C or C++ project in C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition:
1.
2.
3.
4.
5.
6.

Switch to the C/C++ perspective.


Select FileNewProject to open the New Project Wizard.
Expand the C/C++ folder and select C Project or C++ Project depending on the programming language you wish to use.
Click Next to open the C Project page.
Enter a project name in the Project name text box.
Select the Hello World ANSI Project under the Executable folder in the Project type listbox.
Note This tutorial uses the Hello Word ANSI Project for instructional purposes. You can select any project type that fits your
needs.
7. Select Cross GCC in the Toolchains listbox to enable cross-compilation, which configures the compiler to create executable
code for embedded systems, such as your NI Linux Real-Time target.

8. Click Next to open the Basic Settings page.


9. Enter the basic properties of your project in the Author, Copyright notice, Hello world greeting, and Source text boxes.
Note The Source text box specifies the directory on your development computer hard drive used to store the project
source code.

2/12

www.ni.com

10. Click Next to open the Select Configurations page.


11. Enable Debug to configure the project to allow debugging your executable, and/or enable Release to configure the project to
allow building a smaller, faster executable optimized for release.
Note For purposes of this tutorial, ensure you enable Debug.

12. Click Next to open the Cross GCC Command page.


13. In the Cross compiler prefix text box, enter one of the values from the following list, including the hyphen (-) at the end, to
specify the correct compiler for your NI Linux Real-Time target:
(ARM-based targets, 2013 software stack) arm-none-linux-gnueabi(ARM-based targets, 2014 software stack) arm-nilrt-linux-gnueabi(Intel x64-based targets, 2014 software stack) x86_64-nilrt-linux14. In the Cross compiler path text box, browse to the location of the correct compiler for your target as specified in the following
list:
(ARM-based targets, 2013 software stack) \<National
3/12

www.ni.com

14.

(ARM-based targets, 2013 software stack) \<National


Instruments>\Eclipse\toolchain\gcc-4.4-arm\i386\bin
(ARM-based targets, 2014 software stack) \<National
Instruments>\Eclipse\14.0\arm\sysroots\i686-nilrtsdk-mingw32\usr\bin\armv7a-vfp-neon-nilrt-linux-gnu
(Intel x64-based targets, 2014 software stack) \<National
Instruments>\Eclipse\14.0\x64\sysroots\i686-nilrtsdk-mingw32\usr\bin\x86_64-nilrt-linux

15. Click Finish to create your project and return to the workbench view.
In the next section of this tutorial, you create an executable build of your project to enable it to run.

5. Creating a Build of a C/C++ Project

Before you can run your project, you need to test that your source code compiles by creating an executable build of your project.
Complete the following steps to create an executable build of a C/C++ project:
1. Switch to the C/C++ perspective.
2. Modify the template source code if you want to adapt the template to your application needs, or enter C/C++ code if you
selected a blank project. For purposes of this tutorial, you do not need to make changes to the Hello Word ANSI Project source

code.

3. Right-click your project in the Project Explorer tab and select Properties.
4/12

www.ni.com

3. Right-click your project in the Project Explorer tab and select Properties.

4. Select C/C++ Build in the left pane of the Properties dialog box.
5. Select Internal builder from the Builder type pull-down menu for the Debug configuration. Selecting the internal builder uses
C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition (instead of an external build file) to build the executable.
Note For purposes of this tutorial, you work only with the Debug configuration, but this section also applies to the Release
configuration.

6. (ARM-based targets) Complete the following steps to improve the performance of floating-point operations:
1. Select Settings under C/C++ Build in the left pane of the Properties dialog box.
2. Select Miscellaneous under Cross GCC Compiler in the Tool Settings tab.
3. In the Other flags text box, add a space after the existing text, and then enter -mfpu=vfpv3 -mfloat-abi=softfp
7. Click Apply and then OK to close the Properties dialog box.
8. Select ProjectBuild Project in the workbench view to create an executable of your project.

9. The Console tab displays Build Finished if the build completes successfully, as shown in the following image.
5/12

www.ni.com

9. The Console tab displays Build Finished if the build completes successfully, as shown in the following image.

In the next section of this tutorial, you prepare to run the executable on your NI Linux Real-Time target by adding your target to the
project.

6. Configuring a Remote System

Before you can run the executable you created in the previous section on your NI Linux Real-Time target, you need to add your
target to the project. Complete the following steps to configure your target as a remote system in C/C++ Development Tools for NI
Linux Real-Time, Eclipse Edition:
Note Before proceeding with the steps in this section, ensure your target has SSH enabled. You can enable SSH on your
target using Measurement & Automation Explorer (MAX) or using a DIP switch on your target (if available).
1. Select WindowOpen PerspectiveOther to open the Open Perspective dialog box.

2. Select Remote System Explorer.

3. Click OK to add the Remote System Explorer perspective to the workbench.


4. Click the Define a connection to remote system button, circled in the following image, to open the New Connection wizard.

5. Select SSH Only under the General folder.


Note You also can select Linux as the remote system type, but since connecting to NI Linux Real-Time targets requires
SSH, selecting SSH Only shortens the number of configuration steps by pre-selecting SSH options.

6/12

www.ni.com

6. Click Next to open the Remote SSH Only System Connection page.
7. Select a profile to contain the remote system connection from the Parent profile pull-down menu. For information about
profiles, refer to the Remote System Explorer Profiles topic of the C/C++ Development Tools for NI Linux Real-Time, Eclipse
Edition Help, available by selecting HelpHelp Contents from the workbench view.
8. Enter the hostname or IP address of your NI Linux Real-Time target in the Host name text box.
Tip You can use MAX to identify your target's hostname and IP address.
9. (Optional) Enter a description or change the connection name in the Description and Connection name text boxes to help
you identify your target when it appears in the Remote System Explorer perspective.

10. Click Finish.

11. Your target displays in the Remote Systems tab in the Remote System Explorer perspective, as shown in the following image.
7/12

www.ni.com

11. Your target displays in the Remote Systems tab in the Remote System Explorer perspective, as shown in the following image.

12. Expand the Sftp Files folder under your target to explore the files on your target.
13. When prompted, enter the user name and password assigned to your target and click OK. The default user name is admin and
the default password is a blank password.
Note National Instruments recommends you set a password for improved security. For information on setting a password,
refer to the Logging in to your System topic of the Measurement & Automation Explorer Help, available by selecting
HelpMAX Help from MAX.

Note If the connection pop-up does not include a User ID field, please right-click on your target under the Remote
Systems tab and click Properties. You can update the User ID input by changing the Default User ID option in the Host
category.
With a successful logon, you establish an SSH connection to your target and enable transferring files to it. In the next section of
this tutorial, you copy and run a C/C++ executable on your target.

7. Running a C/C++ Executable on Your NI Linux Real-Time Target

At this point in the tutorial, your project contains a target and an executable. Complete the following steps to run your C/C++
executable on your target:
1. Select RunRun Configurations to open the Run Configurations dialog box.
2. Select C/C++ Remote Application in the left pane.
3. Click the New launch configuration button, circled in the following image, to specify settings for running an executable on

your target.

4. Select your target from the Connection pull-down menu.


5. Click the Browse button beside the Remote Absolute File Path for C/C++ Applications text box to open the Select Remote
C/C++ Application File dialog box.

6. Right-click the My Home directory in the listbox and select NewFolder to create a folder on the target in which to place a copy
8/12

www.ni.com

6. Right-click the My Home directory in the listbox and select NewFolder to create a folder on the target in which to place a copy

of the executable.

7. Enter a name for the folder you created in the previous step in the New folder name text box.

8. Click Finish to return to the Run Configuration dialog box.


9. Append your project name (or whatever name you wish to assign to the executable) to the file path populated in the Remote
Absolute File Path for C/C++ Applications text box.
Note This text box specifies the file path (including the executable name) on your target where the compiler copies the
executable. In this example, the file path reads /home/admin/ProjectFolder/MyProjectName, where
MyProjectName defines the executable name, as shown in the following image.

9/12

www.ni.com

10. Click Apply and then Run to copy and run the executable on your target.
11. The program execution displays in the Console tab, as shown in the following image.

In the next section of this tutorial, you explore the debugging functionality available in C/C++ Development Tools for NI Linux
Real-Time, Eclipse Edition.

8. Debugging a C/C++ Project

C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition offers functionality for debugging your project. Complete the
following steps to debug a C/C++ project in C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition:
1.
2.
3.
4.

Select RunDebug Configurations to open the Debug Configurations dialog box.


Select the Debugger tab.
Click the Browse button beside the GDB debugger text box.
Select the correct debugger as specified in the following list:
(ARM-based targets, 2013 software stack) arm-none-linux-gnueabi-gdb.exe in the <National
Instruments>\Eclipse\toolchain\gcc-4.4-arm\i386\bin directory
(ARM-based targets, 2014 software stack) arm-nilrt-linux-gnueabi-gdb.exe in the <National
Instruments>\Eclipse\14.0\arm\sysroots\i686-nilrtsdk-mingw32\usr\bin\armv7a-vfp-neon-nilrt-linux-gnu
directory
(Intel x64-based targets, 2014 software stack) x86_64-nilrt-linux-gdb.exe in the <National
Instruments>\Eclipse\14.0\x64\sysroots\i686-nilrtsdk-mingw32\usr\bin\x86_64-nilrt-linux directory

5. Click Open.

6. Click Apply and then Debug to start debugging the project.

10/12

www.ni.com

6. Click Apply and then Debug to start debugging the project.


7. Click Yes when C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition, prompts you to switch perspectives.
Exploring the Debug Perspective

The Debug tab in the upper left displays the call stack of each running thread.

The Variables tab in the upper right lists C/C++ variables in your source code.

The project tab in the center left displays source code and highlights lines as they execute.
Tip You can hover your cursor over the source code to display detailed information about a function or variable.

To add a breakpoint, highlight a line of code and select RunToggle Breakpoint. A breakpoint suspends the execution of a
program at the location where the breakpoint is set.
Exploring the Debug Toolbar

The Debug toolbar includes the following buttons:


Instruction Stepping
Mode
Drop to Frame
Use Step Filters
Step Return
Step Over
Step Into
Resume
Suspend
Terminate
Disconnect

Enables instruction stepping mode to examine a program as it steps into disassembled code.
Re-enters the selected stack frame in the Debug view.
Enables step filters in the Debug view.
Continues execution to the end of the current routine, then follows execution to the caller of the
routine.
Executes the current line, following execution inside a routine.
Executes the current line, including any routines, and proceeds to the next statement.
Resumes execution of the currently suspended debug target.
Halts execution of the currently selected thread in a debug target.
Ends the selected debug session and/or process.
Detaches the debugger from the selected process.

9. Related Information

C/C++ Embedded System Design Tools (http://digital.ni.com/express.nsf/bycode/exn9da)


C Support for myRIO (http://digital.ni.com/express.nsf/bycode/CmyRIO)
10. Legal Information

Copyright
20132015 National Instruments. All rights reserved.
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including
photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written
consent of National Instruments Corporation.
National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by
copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging
to others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any
applicable license or other legal restriction.
End-User License Agreements and Third-Party Legal Notices
You can find end-user license agreements (EULAs) and third-party legal notices in the following locations after installation:
Notices are located in the <National Instruments>\_Legal Information and <National Instruments>
directories.
11/12

www.ni.com

directories.
EULAs are located in the <National Instruments>\Shared\MDF\Legal\license directory.
Review <National Instruments>\_Legal Information.txt for information on including legal information in installers
built with NI products.
U.S. Government Restricted Rights
If you are an agency, department, or other entity of the United States Government ("Government"), the use, duplication,
reproduction, release, modification, disclosure or transfer of the technical data included in this manual is governed by the
Restricted Rights provisions under Federal Acquisition Regulation 52.227-14 for civilian agencies and Defense Federal Acquisition
Regulation Supplement Section 252.227-7014 and 252.227-7015 for military agencies.
IVI Foundation Copyright Notice
Content from the IVI specifications reproduced with permission from the IVI Foundation.
The IVI Foundation and its member companies make no warranty of any kind with regard to this material, including, but not limited
to, the implied warranties of merchantability and fitness for a particular purpose. The IVI Foundation and its member companies
shall not be liable for errors contained herein or for incidental or consequential damages in connection with the furnishing,
performance, or use of this material.
Trademarks
Refer to the NI Trademarks and Logo Guidelines at ni.com/trademarks (http://digital.ni.com/express.nsf/bycode/rdtrad) for
information on National Instruments trademarks. Other product and company names mentioned herein are trademarks or trade
names of their respective companies.
Eclipse is a trademark of Eclipse Foundation, Inc.
Patents
For patents covering the National Instruments products/technology, refer to the appropriate location: HelpPatents in your
software, the patents.txt file on your media, or the National Instruments Patent Notice at ni.com/patents (
http://digital.ni.com/express.nsf/bycode/rdlv17).
Customer Reviews

1 Review | Submit your review (


http://zone.ni.com/apps/utf8/nidz_display_comments.create_comment?p_title=Getting+Started+with+C%2FC%2B%2B+Development+Too
)

PRODUCT

SUPPORT

COMPANY

Order status and history (http://www.ni.com/status/)

Submit a service request (


https://sine.ni.com/srm/app/myServiceRequests)

About National Instruments (http://www.ni.com/compa

Order by part number (


http://sine.ni.com/apps/utf8/nios.store?action=purchase_form)

Events (http://www.ni.com/events/)
Manuals (http://www.ni.com/manuals/)
Careers (http://www.ni.com/careers/)

Activate a product (
http://sine.ni.com/myproducts/app/main.xhtml?lang=en)

Drivers (http://www.ni.com/downloads/drivers/)
Alliance Partners (http://www.ni.com/alliance/)

Order and payment information (http://www.ni.com/how-to-buy/)

MISSION
NI equips engineers and scientists with systems that accelerate productivity, innovation, and discovery.

(http://twitter.com/niglobal)

(http://www.facebook.com/NationalInstruments)

(http://www.linkedin.com/company/3433?trk=tyah)

(http://www.youtube.com/nationalinstruments)
Contact Us (http://www.ni.com/contact-us/)

(http://privacy.truste.com/privacy-seal/National-Instruments-Corporation/validation?rid=bc6daa8f-7051-4eea-b7b5-fb24dcd96d95)
Legal (http://www.ni.com/legal/) | National Instruments. All rights reserved. | Site map (
http://www.ni.com/help/map.htm)

12/12

www.ni.com

(http://

You might also like