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 1937 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
  • sw.teach.me
    sw.teach.me over 9 years ago

    Hi Enrico and thanks for the article.


    I tried to follow it on Windows 7 and failed.

    I failed to add GNU Compiler and also failed to Edit the Build Host to pi@10.0.0.7 (My Pi).

     

    Can you please Create or Update that article to support Windows 7?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • sw.teach.me
    sw.teach.me over 9 years ago

    Hi Enrico and thanks for the article.


    I tried to follow it on Windows 7 and failed.

    I failed to add GNU Compiler and also failed to Edit the Build Host to pi@10.0.0.7 (My Pi).

     

    Can you please Create or Update that article to support Windows 7?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • balearicdynamics
    balearicdynamics over 9 years ago in reply to sw.teach.me

    Hello Ro,

     

    I am sorry but I think no, at least for now. The two most important reasons are because this article is part of a specific project; the first phase is closed - due the challenge deadline - but the project is still in progress for at least the next three months. The second more important aspect is that all that is related to Meditech is a full open project (software, schematics, development environments) and the entire architecture approach is based on opensource components and development environments.

     

    Instead I think that it should be possible to set a gnu toolchain to compile C under windows. But my question is why? The C++ part has been developed in a IDE - NetBeans - just because it is platform independent. You don't need to compile, or try to, with the GNU toolchain under windows. You can easily setup the NetBeans for Windows (W7 is certainly compatible) and compile remotely on the Raspberry PI. That is the goal of this mechanism.

     

    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • sw.teach.me
    sw.teach.me over 9 years ago in reply to balearicdynamics

    Hello Enrico,

     

    That is exactly what I'm looking for, compile remotely on Raspberry PI while using Win7.

     

    Hope I'll find another tutorial with windows 7 in mind.

     

    Best regards

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 9 years ago in reply to sw.teach.me

    Hello Ro,

     

    Well, what is explained in this post is exactly what you need image You should setup NetBeans installed with Windows version in the same way. I have used the Mac version simply because I develop on a Mac. Then if some issue arises in your settings, these are not related to the GNU, compiler etc (that are on the Raspberry PI) nor the Raspi the same. You should set Windows as NetBeans windows installation explain. Then the job is done by the IDE.

     

    Just a suggestion; did you have enabled the SSH remote access on the Raspberry PI with the raspi-config command? If not, you can connect in any way, including from NetBeans to the Raspberry PI via SSH. Another detail maybe to check the Raspberry PI IP address that should be set in the NetBeans IDE.

     

    Let me know if something change or if there are again problems and what are.

     

    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • sw.teach.me
    sw.teach.me over 9 years ago in reply to balearicdynamics

    Hi Enrico,

     

    I finally succeeded, The GNU tool collection came automatically right after setting up the Build Host connection to Raspberry PI.

    Thanks a lot for this great tutorial.

     

    Another issue that maybe you came across:

    I'm developing opencv app that display some graphics using GTK (load image into window).

    When I'm running the application from NetBeans I get this error "Gtk-WARNING **: cannot open display:"

    While running the exact same executable from the raspberry itself it runs as expected.

    From my understanding it tries to open the windows at my local machine (Win 7) and not at the Raspberry PI.

    Do you know how to force opening the windows at the raspberry itself or any other solution?

     

    Best,

    Ro

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 9 years ago in reply to sw.teach.me

    This may depend on the remote ssh access you set, I think. Try setting the ssh call to remote with the -X parameter that send back also the graphic X to the remote. Maybe helpful, but I have not yet tested this specific environmnet.

     

    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