corner imagecorner image
IDEPlatformPluginsDocs & SupportCommunityPartners

C/C++ Remote Development - NetBeans IDE 6.8 Tutorial

Contents

Content on this page applies to NetBeans IDE 6.8
Introduction
Setting Up the System
Setting Up the IDE
Workflow

Requirements

To follow this tutorial, you need the following software.

Software Version Required
NetBeans IDE (including C/C++ support) Version 6.8
Java Development Kit (JDK) Version 6 or version 5
C and C++ compilers, make, gdb C/C++ Tool Collections Tested with NetBeans IDE

See the NetBeans IDE 6.8 Installation Instructions and Configuring the NetBeans IDE for C/C++/Fortran
for information about downloading and installing the required software.

Introduction

This tutorial demonstrates how to use remote development of C/C++ projects. Have you ever wanted to develop a SolarisTM or Linux application from your laptop running Windows Vista? To test your application on different operating systems without even leaving the IDE? Or just to compile your large applications on a fast multicore server rather than on your regular workstation. The answer to all these needs is the remote development functionality in the NetBeans IDE 6.8.

Please take a look at this tutorial to find out how to use this feature.

Conception

Remote development works this way:
Run the NetBeans IDE on your client system and you can create projects, edit files, and use code assistance features the same way as you do for local projects. But when you build, run, or debug your project, the process runs on the remote server with output and input transferred to the client system. So, ideally, you shouldn't see any difference in workflow between doing local and remote development once you've set up the remote development host.

The elements that must be in place to enable the use of a remote host for running your tools are:

  • The local client system and remote system must have access to the project files, either through shared resources, or through use of a secure copy command, scp.
  • The client must be able to connect to the remote system through a secure shell (ssh).
  • The remote system must have the supporting system libraries that your project needs.

Each of these requirements are explained below.

Sharing sources

Both your client system and your remote server have to know about your source files. The source files can reside on a shared network path, or can be copied securely by the IDE from the local system to the remote system. In the section Setting Up the System you can find more details about ways to set up shared folders for different systems.

Connectivity

All data transfer between client and server except shared network path is done through the Secure Shell (SSH) protocol. SSH is a common protocol for secure communications between two networked devices. Your server has to have the SSH server installed, and SSH connection between the client system and the server should be allowed.

Code Assistance

For correct support of editor features like code completion and semantic highlighting, the Classes window, and others, your project has to be used in the correct environment, which means system includes, macro definitions, platform, etc. All of this information is gathered from the remote server and stored locally on your client system. You can manage the tool collection for the remote server mostly the same way as for client system and the code assistance features will use the corresponding environment.

Setting Up the System

Your remote server must allow communication through the SSH protocol from the client where you are running the IDE. If you want to use file sharing instead of allowing the IDE to copy files to the remote server, the file sharing must be set up in the network for both systems.

SSH protocol

The SSH server is usually included in Linux and Solaris operating systems, and is run by default in most cases. If not, you can find information about installing and managing SSH at http://en.wikipedia.org/wiki/Secure_Shell

Also an SSH connection must be allowed between your client and server systems, which usually means port 22 must be open on the server. You may need root access or the help of your system administrator if port 22 is disabled.

The secure copy (SCP) protocol and scp command is part of SSH, and can be used to copy the project files if you choose.

Sharing sources

For Windows to UNIX® configuration there are two major ways of sharing sources:

  • Samba server on UNIX system
  • Windows Services for UNIX (SFU) package installed on Windows system

Organizing sources using Samba

A Samba server allows a Windows user to map shared NFS folders as Windows network drives. The Samba package is included in most distributions of Linux and Solaris operating systems. If it's not included in your distribution, you can download it from www.samba.org

If you have root access on your server, you can set up Samba yourself following the simple instructions at the following links. Otherwise you have to contact your system administrator.

After starting Samba you can map your UNIX server's folders the same way as Windows folders.

Windows Services For UNIX (SFU)

Another option is Services For UNIX. This is the set of utilities provided by Microsoft to access NFS filesystems from Windows.
You can download them here: http://technet.microsoft.com/en-us/interopmigration/bb380242.aspx

The SFU package is not available for Windows Vista users.

Windows Vista Enterprise and Ultimate Editions include the Services for Unix components, renamed to the Subsystem for UNIX-based applications (SUA), and Client for NFS v3. For more information, see http://en.wikipedia.org/wiki/Microsoft_Windows_Services_for_UNIX

UNIX-UNIX configuration

For connection between Solaris or Linux systems you don't need any special setup. You just need to have a shared folder on one of the systems or you can use your home directory if it is mounted on a network file server and accessible from both systems.

Path Mapping

When using the shared sources model, you may need to map the location of the sources on the local host, to the path used on the remote host to get to the sources.

For example, consider this configuration:

  • Solaris server solserver with shared folder /export/pub
  • Workstation running Windows XP with installed SFU and path \\solserver\export\pub is mounted as drive P:
  • Project source files located on solserver in the folder /export/pub/myproject

In this case from the server point of view your source files are located in the /export/pub/myproject. But from the client point of view the location of the source files is P:\myproject. Hence you need to let the IDE know that these paths are mapped:

/export/pub -> P:\

If you set up shared resource for source files before configuring the remote host in NetBeans IDE, the IDE will automatically find out the required path mappings for you in most cases.

Setting Up the IDE

In the following example, the client host is a workstation running Windows Vista. The remote host named b20 is a server running the Solaris OS. For source sharing, the Samba server is running on the remote host, which allows the /export/pub folder to be accessed as pub.

On the Windows client, drive P: is mapped to \\b20\pub using the following command

net use P: \\b20\pub /persistent:no /USER:tester
Such mappings are not required and are done for more convenience.

  1. Start the IDE and choose Tools > Options.
  2. Click C/C++ in the top pane of the window.
  3. Click the Build Tools tab.
  4. By default, the Development Host drop-down list includes only localhost, which represents your current workstation. To add a new host for remote development, click Edit.
  5. In the Development Hosts Manager dialog box, click Add. In the New Remote Development host dialog box, the IDE discovers your network's hosts. The host names are added to a table in the dialog box, and marked Available if they are running the SSH server.
  6. Double-click the name of the server you want. You can also type a server name in the Hostname field if you prefer. Click Next.
    Image showing the Process of Adding New Host for Remote Development.


  7. On the Setup Host screen, type the username and password that you use to log in to the remote host, and click Next.
    Image showing the Process of Connecting to the Remote Development Host.


  8. The output shows the IDE's attempt to connect to the server and locate a tool collection. When the host is successfully configured, a summary page shows information about the remote host: the platform, hostname, user name to log in, and the tool collections that were found.
    Image showing the Completion of Adding a New Host for Remote Development.
  9. At the bottom of the summary page, two more options are displayed. If more than one toolchain was found, you can select one of the toolchains to be the Default toolchain.
  10. For the Synchronization option:
    • Select Smart Secure Copy if your client system and the remote development host do not have shared filesystem access to the project files. When you select Smart Secure Copy, the project files will be copied to your home directory on the server using the scp or sftp command.
    • Select File System Sharing (no synchronization) if the client and server have access to the same file system.
  11. Click Finish, and you return to the Development Hosts Manager dialog box.
  12. Optionally, if you are using File System Sharing, you can click Path Mapper... in the Development Hosts Manager dialog box to view and if necessary correct mappings for the shared source location on the local and remote hosts. Note that each path is the path to the shared source as seen from the respective hosts. If you need to edit either the local or remote path, double-click the path you want to change and type the new path.
  13. Image showing the Path Mapping window.
  14. Close the Development Hosts Manager dialog box by clicking OK. From the Development Host drop-down list, choose the newly added remote host if it is not already selected.

    At this point, you should have one or more tool collections in the Tool Collection list. A tool collection is a set of compilers and debugger to work with your projects. If you don't have any tool collections you can find out how to set up them in Configuring the IDE for C/C++/Fortran.

    You can click Restore Defaults to try to find tool collections again or add a tool collection by clicking Add if you know the exact path on the remote server. If you add a tool collection on a remote server, you must type the full path to the base directory of the tools. The IDE may take a few moments to add the remote server's tool information to the local host's configuration for the remote server.

    Image showing Remote Tool Collections.


  15. Click OK to close the Options window and you are done with creating new remote development hosts. Let's see how can you use it for development.

Workflow

  1. Let's create a new sample project by choosing File > New Project. If you want to use shared source files, make sure that as a Project Location you are choosing a path that is shared with the remote server. In the example case the path is disk P:.
    Image showing Remote Tool Collections.


  2. If you leave the new remote host selected in the Development Host drop-down list in the Options window, the new created project should be already set up to use it. You can check this by right-clicking on the project node and choosing Set Remote Development Host. The currently active development host is marked, and you can also select a different host from here.
  3. Image showing Set Remote Hosts Menu.


  4. Now click Build on the toolbar or right-click the project node and choose Build, and the sample project will be built remotely on the selected development host. In the following screenshot you can see that your source file is located on the local machine and all code assistance support is working. In the Output window you can see the name of the host where the application was built and that remote compilers were used for building.
    Image showing Output of Build.
  5. There is almost no difference in workflow once you set up a remote host. You can use all editor features, build, run, and debug as you are used to doing locally.

    Note:Running an application with a UI is not yet supported, so your UI will display only the monitor, attached to remote host (if there is any).