Pergunta

I'm trying to set up Code::Blocks under Windows 7 Professional SP1 to work for remote compilation (using PuTTY link -> plink) on a linux server, but I am not much familiar with that topic. This is the manual I used:

http://wiki.codeblocks.org/index.php?title=Using_Xming_for_remote_compilation

I configured Code blocks as follows:


Settings->Compiler and debugger->Global compiler settings->Toolchain executabes:

Program Files->Make program: plink.exe


Project->Properties->Project Settings:

Makefile: makefile_name

[checked] This is a custom makefile

Execution direction: Z:\Path\to\Samba\Share


Project's build options->Debug->"Make" commands:

Build project/target:

$make -X -ssh user@linux_server -pw my_great_password make -f $makefile -C /path/to/my/makefile

Compile single file:

$make -X -ssh user@linux_server -pw my_great_password make -f $makefile -C /path/to/my/makefile $file

Clean project/target:

$make -X -ssh user@linux_server -pw my_great_password make -f $makefile clean -C /path/to/my/makefile

Ask if rebuild is needed:

$make -X -ssh user@linux_server -pw my_great_password make -q -f $makefile -C /path/to/my/makefile

Silent build:

$make -X -ssh user@linux_server -pw my_great_password make -s -f $makefile -C /path/to/my/makefile

By the way, do I invoke the compiler/linker on the linux server or is Code::Blocks itself compiling and linkung the source on the linux server? Excuse my nescience.


The problem I am facing now, is that I can not access environment variables in the makefile:

include $(MY_ENV_VAR)/path/to/another/makefile

The error I receive let's me assume, that MY_ENV_VAR remains empty:

/path/to/another/makefile: No such file or directory

I checked if Code::Blocks tries to resolve the environment variable of my windows computer but that is not the case.


Additional information:

Code::Blocks version:

Version: 10.05, Build: May 27 2010, 19:10:05 - wx2.8.10 (Windows, unicode) - 32 bit

Linux server:

Linux linux_server 2.6.18-238.el5 #1 SMP Sun Dec 19 14:22:44 EST 2010 x86_64 x86_64 x86_64 GNU/Linux

I can provide more information if needed. I also welcome other suggestions to realize a remote compilation on a linux machine from windows. Or is another IDE more suitable for doing remote compilation?

Thanks for reading/helping.


Edit:

I found someone having a similar problem with NetBeans IDE:

http://forums.netbeans.org/topic37974.html

Foi útil?

Solução

According to this stackoverflow post and this fixunix post I could figure out, that plink doesn't execute startup scripts as it is the case, when you connect via putty. So I realized that Code::Blocks was innocent concerning my difficulties while trying to remote compile.

In my case, I had to explicitly source the login script ~/.login to have access to my environment variables. For the make command this would for example mean:

$make -X -ssh user@linux_server -pw my_great_password "source ~/.login;make -f $makefile" -C /path/to/my/makefile

This way a managed to remote compile my software. To start the application, I added a post-build step:

cmd /c "C:\Program^ Files\PuTTY\putty.exe -load my_session -pw my_great_password"

In the password, I had to escape an ampersand character: ^& (by the way, there are many reasons to use a private key instead of a hardcoded password). This loads a stored PuTTY session, which has the following remote command(s):

source ~/.login;/path/to/my/application/my_application;$<

I'm using the C shell. Therefore I used $< to wait for an user input (enter key). Now I can compile and run my application by hitting the build button. Hope this helps others to configure Code::Blocks for remote compilation. Just leave a comment if you're facing further problems or if you want to provide additional information/advice.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top