element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sci Fi Your Pi
  • Challenges & Projects
  • Design Challenges
  • Sci Fi Your Pi
  • More
  • Cancel
Sci Fi Your Pi
Blog Meditech Annex I - Setting a C++ Development Environment for Raspberry PI
  • Blog
  • Forum
  • Documents
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: balearicdynamics
  • Date Created: 9 Aug 2015 12:42 PM Date Created
  • Views 1941 views
  • Likes 3 likes
  • Comments 8 comments
  • meditech_project
  • gnu_cc
  • remote_compiling
  • winners
  • raspberry-pi
  • development_ide
  • sci_fi_your_pi
  • cpp
  • netbeans
Related
Recommended

Meditech Annex I - Setting a C++ Development Environment for Raspberry PI

balearicdynamics
balearicdynamics
9 Aug 2015

This post is an annex to the Meditech project explaining one of the (possible) best practices to setup an efficient development environment for C++ developing on the Raspberry PI platform with the advantage of an advanced IDE and remote compiling without emulators.

 

Why a development IDE

When C/C++ language programming covers a large part of an embedded project going far beyond the simple cut and paste of some examples, to be able working in a good development environment represent a success factor for code quality and usability; adopting a high level programming IDE become a must at least for the following reasons:

  • Availability of optimized editing tools, including language syntax-checking
  • Fast moving between sources and headers inside a well organized project
  • Easy accessibility to classes, function declarations, constants, commenting
  • Fast syntax checking and bug-tracking
  • Sources and headers organization in projects
  • Optimized compiling feedback and fast error checking
  • Local and remote sources replication in-synch

 

Note that the use of a PC with a high level IDE creating code for different platforms (mostly embedded devices) where it is difficult or impossible to develop it is a widely diffused practice. This is the way adopted at least for the following well-known devices:

    • All Android based devices
    • Symbian devices (already diffused in the Indian and some south-world countries)
    • iOS smartphones and iPad
    • Arduino
    • ChipKit and many PIC based microcontrollers
    • Many other SoC and SBC

 

These and many other factors dramatically increases the productivity and the quality of the final result when working with a remote compiling enabled IDE.

image

 

What IDE for the Raspberry PI

The first assumption is that the Raspberry PI linux (here it has been used raspian but the concept is the same with other distributions) should not host the development environment as it is the target of the project. So we should think to the better way to manage the code development on a PC seeing the result real-time on the target device. In few words, we will provide a simple network connection between the Raspberry PI and the development PC; we can use the WiFi, the LAN connection, the home router or any other method so that the two machines can share their resources on the network.

 

The other assumption is that for the best result it should be possible to compile remotely with few simple operations, fast checking errors and compilation results in the IDE on the PC, running the program over the native platform.

 

The two most popular open source IDE for multi-language development are Eclipsehttp://www.eclipse.org/ and NetBeanshttps://netbeans.org/. There is an alternative to the remote compilation using a cross-compiler: with a particular settings it is possible to compile on a different hardware architecture (i.e. a PC with a Intel-based CPU) the code that should run on the Raspberry PI that is, an ARM based architecture. It is a more complex way with so few advantages that where it is possible it is best to avoid this method.

 

Just an interesting note: the PC Arduino IDE represent a good effort in this direction, as well as the MPIDE supporting also the ChipKit PIC based platforms. It is a simple (and a bit primitive) IDE making a cross-compilation of the program before uploading the binary file to the micro controller board.

 

I am used to base many of my developments on the Eclipse IDE as this is one of the privileged Android, Java and Php develompent tools. Unfortunately after some tests I saw too many issues when trying to connect the networked Raspberry PI for remote compiling so I adopted the NetBeans IDE supporting a very simple setup.

 

Minimal requirements for remote compiling

There is a series of minimal requirements that should be accomplished to remote compile C++ programs on the raspberry PI; most of these are obvious but a reminder can be useful:

 

  • SSH and SFTP installed on the Raspberry PI for remote access (this option can be enabled from the raspi-config setup utility)
  • GNU compiler (better to check the system upgrade for the last version of the compiler, assembler and linker)
  • SSH access to the Raspberry PI from the PC
  • Development version of the C++ libraries needed for your needs, correctly installed on the Raspberry PI

 

NetBeans IDE setup on the PC

These notes refers to the version 8.0 of the Netbeans IDE; If a different (maybe newer) version is installed maybe you find some minor changes in the menu settings.

To install a copy of the IDE on your PC it is sufficient to go to the NetBeans IDE platform download page downloading the last available version for yourplatform (Mac, Windows or Linux)

image

The installation is simple and in most cases the default settings are all what you need.

When the installation process end, few things should be changed from the Settings menu. Its location can vary depending on the PC platform you are using; in the Mac OSX it is in the pull-down NetBeans main menu (the topmost left choice) while in Windows and Linux maybe in the File menu.

image

From the settings windows (see the image above) you can customize all the features of the IDE, e.g. the editor behavior, source font and colors, the graphic appearance and so on. From the C/C++ option tab select the GNU compiler (it should be the default, else add it updating the IDE with the Add button on the same window).

image

Againfrom the same window you should Edit the host list (by default there is only localhost, the development PC) adding the parameters to connect with the Raspberry pi:

  • Add the user (in this case the default user pi)
  • Add the password and confirm to save it avoiding to repeat it every time the IDE starts connecting to the Raspberry PI
  • Insert the Raspberry PI IP address (better to set a static IP instead of a DHCP assigned to avoid the IP changed the next time you reopen the IDE)
  • Specify the access mode SFTP (that is, FTP protocol over SSH connection)
  • Enable the X11 (the linux graphic server) forwarding

That's all!

 

Starting developing

With the IDE set in this way you can start creating a new project and write your code. On the IDE top toolbar there is the connection button to activate the remote connection with the Raspberry PI. To compile remotely from the PC you should be connected. As the device is remotely connected NetBeans gives you the option to edit the application sources locally but when you Build the application the sources are automatically zipped, sent to the remote device (the Raspberry PI), unzipped and compiled. Errors and messages are shown in the Build result window making the debug very simple.

 

Another very useful feature is the option to open a remote terminal directly from the IDE. In this way, as shown in the following screencast, the development lifecycle included the program running and testing become very simple and efficient with a minimal effort.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 10 years ago +1
    Great article (also because I'm a NetBeans fanboy ). I don't know if I agree with this sentence about cross-compiling: It is a more complex way with so few advantages that where it is possible it is…
Parents
  • Jan Cumps
    Jan Cumps over 10 years ago

    Great article (also because I'm a NetBeans fanboy image ).

     

    I don't know if I agree with this sentence about cross-compiling:

    It is a more complex way with so few advantages that where it is possible it is best to avoid this method.

     

    I think that cross-compilation is a key part of embedded development.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Jan Cumps
    Jan Cumps over 10 years ago

    Great article (also because I'm a NetBeans fanboy image ).

     

    I don't know if I agree with this sentence about cross-compiling:

    It is a more complex way with so few advantages that where it is possible it is best to avoid this method.

     

    I think that cross-compilation is a key part of embedded development.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to Jan Cumps

    Hi Jan,

    I don't know if I agree with your sentence about my sentence about cross-compiling.

    I don't know if I agree with this sentence about cross-compiling


    In an absolute vision I think you can't negate that it is faster the NetBeans (another fan is here, by the time when the IDE was orange 1.0 version and Eclipse was not yet in the mind of the developers) remote compilation method than the cross-compiling platform itself. One of the major issues I find in the cross-compilation mechanisms is that in most cases the linux development machine should be dedicated so when I had to test for example Ltib cross compiler settings respect OpenWRT and a couple of other minimal Linux distro on the same platform the only was was to setup different machines. The same for a job for a client that has been developed with Damn Small Linux etc. But I agree with you that cross-compilation is the base for the embedded development, especially when the embedded platform is not Linux but a microcontroller (NXP, Avr, PIC etc.) And also in these cases the problem is always that for every optimal environment a virtual machine should be dedicated.


    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube