This tutorial demonstrates how to use a new feature of NetBeans 6.5:
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 new remote development functionality in the
NetBeans IDE 6.5.
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 host.
Sharing sources
Both your client system and your remote server have to know about your source
files. There are two ways of making this possible:
Put the source files on the shared network path
Keep the source files on the client machine and copy them to the server
if there are any changes.
NetBeans IDE 6.5 supports only the first option. In the next section
(Setting Up the System) you can find more details about ways to set
up shared folders for different systems.
Connectivity
For all other data transfer between client and server, the Secure Shell (SSH)
protocol is used. 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 for each server. 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
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 SSH connection should be allowed between your client and server
systems, which usually means port 22 is open on both systems and a
firewall is set up to allow the NetBeans IDE to perform such connections. You
may need root access or the help of your system administrator if port 22
is disabled.
Sharing sources
For Windows to UNIX® configuration there are two major way 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.
Unfortunately this package is not available for Windows Vista users (except Vista Ultimate).
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.
Path Mapping
Due to the shared sources model, you may need to set up a mapping between remote and local hosts.
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 a shared resource for source files beforehand
NetBeans will automatically find out the required path mappings for you in
most cases.
Setting Up the IDE
The following example uses this system configuration:
The client host is a workstation running Windows Vista.
The remote host named eaglet-sr is a workstation 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
\\eaglet-sr\pub using the following command
net use P: \\eaglet-sr\pub /persistent:no /USER:tester
Such mappings are not required and are done for more convenience.
Start the IDE and choose Tools > Options.
Click C/C++ in the top pane of the window.
Click the Build Tools tab.
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.
In the Development Host Manager dialog box, click Add. In the Add New Server dialog box,
type the name of the host in the Development Server field.Change the default Login name if needed.
Type your password in the Password field and click OK.
Wait for the progress bar to finish. Now you have your remote server set
up. You can click Path Mappings to correct mappings between remote
and local hosts.
Now close the Edit Path's Map and Development Hosts Manager dialog boxes
by clicking OK. From the Development Host drop-down list, choose the newly
created remote host.
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 you can find out how to
set up them in Installing and Configuring C/C++ Support.
You can click Restore Defaults to try to find
tool collections again or add a tool collection by clicking Add if you
know exact path on the remote server.
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
Let's create a new sample project by choosing File > New Project.
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:.
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 setup to use it. You can check this by right-clicking on the project
node, choosing Properties, and selecting Build > Development Host in the
Properties dialog box.
Now click Build on the toolbar or right-click the project node and choose
Build, and the sample project will be built remotely.
In the following screenshot you can see that your source file is
located on the client machine and all code assistance support is working.
And 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.
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).