Using Xming for remote compilation

From Code::Blocks

Introduction

This article explains how to set up true remote compilation, without using any local file stores. Note that it assumes a custom makefile, and that to actually edit your files in C::B, the remote source directories must be shared, and mapped to a local drive. Typically this will use a samba share on the remote system, but it is possible to map FTP or SFTP servers to windows drives as well.

The method described is for remote compiling where C::B is running on a windows system, and the remote compilation is to take place on a linux system. An instance of C::B running on Linux or Mac should be able to use a similar method, using 'ssh' as the 'make' command, employing a 'keys' file to avoid being prompted for an ssh password.

Method

Step 1

Download and install Xming (windows X server) from http://sourceforge.net/projects/xming/ . It will sit in the systray.

Step 2

Open or create your project, and choose any compiler you have installed that actually works (i.e. doesn't give you an 'Invalid Compiler' message when you try to build). The easiest way to achieve this is to use the C::B installer that includes MinGW. It doesn't matter if your remote compiler is completely different to the one you choose here.

Step 3:

In the project properties, "Project Settings", select "This is a custom Makefile", <OK>. Now in the project build options, "'Make' Commands", enter:

$make -X -ssh RemoteUser@RemoteIP -pw RemotePassword make all -C /path/to/remote/makefile/

Note that your remote password is stored in plaintext, not everyone will like this! Also, the path to the remote makefile is relative to the root of the remote machine, for example /home/username/myproject.

The make all is specific to my Makefile. You can obviously modify this for the different build types implemented in your Makefile. I set all the make commands to be the same, with the exception of "Clean project/target", where I used make clean, which is implemented in my Makefile. Do this for all the build profiles (in my case, "Debug" and "Release"). <OK>.

Step 4 (nightly builds only)

If you are using a C::B build newer than January 2009, you may need to fill in the "Ask if rebuild is needed" make command in the "'Make' Commands" tab. This is the same command as in step 3, but with make -q in place of make all. For the 11/11/09 nightly build, I had to use make-q (i.e. without the space) for this to work. You must also change "Settings", "Compiler and debugger", "Global compiler settings", "Other settings", "Compiler logging" to "Full command line", or else you will receive a "Nothing to be done." message when you try to build.

Step 5

In "Settings", "Compiler and debugger", "Global compiler settings", "Toolchain executables", change the "Make program" to "plink.exe", and add the Xming install path in the "Additional paths" tab (typically "C:\Program Files\Xming").

Step 6

Build the project. The first time you do this, you will be prompted with a "PuTTY Security Alert". Click "Yes" and the remote server will be added to your list of trusted hosts. Note that if you have used PuTTY before, this can go wrong. If you are being prompted for a username and password, try deleting the registry key "HKEY_CURRENT_USER/Software/Simon Tatham/PuTTY". Note that this could mess up your PuTTY configurations (it might not; this was not checked).