This document describes how to use remote development features of the NetBeans IDE with C/C++/Fortran projects.
|-||Remote Development Concepts|
|-||Setting Up the System|
|-||Setting Up the IDE|
|-||Building a Local Project on a Remote Host|
|-||Starting a Terminal Session on the Remote Host|
|-||Remote Development Tips|
To follow this tutorial, you need the following software.
|NetBeans IDE (including C/C++ support)||version 7.3, 7.4, or 8.0 with NetBeans C/C++ plugin|
|Java Development Kit (JDK)||Version 7 or 8|
This tutorial demonstrates how to use remote development of C/C++ projects.
Have you ever wanted to develop a Solaris or Linux application from your laptop running Windows 7 or Mac OS X? 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 feature in NetBeans IDE.
When you do remote development, you 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 Solaris or Linux server with output and input transferred to the client system. Ideally, you shouldn't see any difference in workflow between doing local and remote development once you've set up the remote build host.
The IDE supports different modes of remote development, which are described in C/C++ Remote Development Modes. You can determine how you want to develop on the remote host.
The elements that must be in place to enable the use of a remote host for running your tools are:
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. See Setting Up the System for more details about how to set up shared folders for different systems.
All data transfer between client and server is done through the Secure Shell (SSH) protocol. SSH is a common protocol for secure communications between two networked devices. Your server must have the SSH server installed, and SSH connection between the client system and the server must be allowed.
The IDE must be able to find a supported tool collection on the remote host: GNU Compiler Collection or Sun Studio or Oracle Solaris Studio. The tools executables should be on the path of the user account used to connect to the remote host, so the IDE can easily locate the tools. This is especially true if the tools are installed in a non-default location.
For correct operation 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, so that when you edit locally the code assistance will work even when the project is set up to use a remote build host.
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
The IDE provides its own ssh client, so you do not need to install the ssh client on your local machine.
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.
SSH must be enabled between the systems even if you are not using the Automatic Copying or SFTP option to transfer the projects files to the remote server.
If you do not already have file sharing set up between your Windows system and a Unix remote host for other uses, it is much simpler to use Automatic Copying or SFTP instead of file sharing for small to medium projects. If you are working on a large project with thousands of files that participate in the build, sharing makes more sense because copying would take a long time.
For Windows to UNIX® configuration there are two major ways of sharing sources:
A Samba server (open source version of SMB) allows a Windows user to map shared NFS folders as Windows network drives. The Samba package, or its equivalent SMB or CIFS, is included in most distributions of Linux and Solaris operating systems. If Samba is not included in your distribution, you can download it from www.samba.org.
If you have privileged access on your server, you can set up Samba yourself following the 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.
Another option is Windows Services For UNIX, a set of utilities provided by Microsoft to
access NFS filesystems from Windows.
You can download them from Microsoft Download Center and read documentation at Windows Services for Unix page.
The SFU package is not available for Windows Vista or Windows 7 users. Windows Vista and Windows 7 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
Mac OS X includes support for connecting to Samba servers. Mac OS X can also mount NFS shares from a server.
You can use Finder > Go > Connect to Server and enter a server address.
To connect to SMB/CIFS (Windows) servers and shared folders, enter the server address in one of these forms:
You are prompted to enter the username and password for the shared folder. See How to Connect to Windows File Sharing (SMB) in the Apple knowledge base for more information.
To connect to an NFS server, type the server name and path to the NFS shared folder in one of these forms:
For more information, see Using the Finder to Mount NFS Exports in the Apple knowledge base.
You are not prompted for your username and password, but authorization is checked against your Mac UID. The UID is a unique integer assigned to your username in Unix-like operating systems such as Mac OS X, Solaris, and Linux. To use NFS, the Mac UID must be the same as the UID of your account on the server.
For file sharing between Solaris or Linux systems, you do not need any special setup. You just need to share a folder from 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.
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:
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.
You need to let the IDE know that these paths are mapped:
/export/pub -> P:\
You can edit the properties of the build host to set path mappings.
If you set up shared resources 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.
In the following example, the client host is a workstation running Windows Vista. The remote host named edgard is a server running the Oracle Solaris operating system.
If you want to use ssh keys, you must set them up outside the IDE first. Then you can specify the location to the ssh keys in the IDE, and the IDE can use the keys to make the ssh connection to the remote build host.
The IDE configures the remote host and looks for tool collections on the remote host.
Try the following tasks if you do not see any tool collections under the remote host node.
When you have a tool collection listed, you are done with creating your new remote build host.
In the next section, you can try simple remote development.
This example does not use shared folders, so you can keep the suggested location for the project in the NetBeansProjects folder in the Windows user directory, which is not shared.
If you want to use shared source files, make sure that the Project Location you specify is a path shared with the remote server.
The Welcome_1 project opens in the Projects window.
In the following screenshot you can see that code assistance is working when you press Ctrl-Space with the cursor on the argc symbol to see.
The Output window displays the name of the host where the application was built and the remote compilers and make utility that were used for building. The project files are in the user's .netbeans/remote/ directory on the remote host.
There is almost no difference in workflow once you set up a remote host. You can use all editor features, build, run, test, and debug as you are used to doing locally.
You can start a secure shell terminal session from within the IDE to connect to the remote system or the local system. This feature is especially convenient on Windows platforms, which do not support SSH natively.
The IDE opens a Terminal tab in the working directory of the current project, whether it is local or remote. If the project is using a remote build host and you are already connected through the IDE, you do not need to login again.
You can use the IDE internal terminal to do anything you might usually do in an SSH session to a remote host.
You can create new local or remote terminal sessions using the icons in the left margin of the Terminal tab, or using the menu option Window > Output > Terminal.
See the following locations for more information:
The Help menu in the IDE provides access to extensive information about using the IDE.
The C/C++ Remote Development Modes article describes different ways to use remote development
The C/C++ Learning Trail provides several articles and tutorials for developing in C/C++ in the IDE.