Editing Free Compiler Setup Under Linux

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
This article explains how to setup a free compiler, MS VC++, under Linux through Wine, under assumption, that [[Orbiter]] itself can be [http://www.orbiterwiki.org/wiki/Running_Orbiter_under_Wine ran under Linux through Wine] for testing your modules. Latest possible setup that is capable of doing it is [http://www.winehq.org Wine 1.6.2] and [http://orbit.medphys.ucl.ac.uk/download.html Orbiter 2016], using the built-in DX7 graphical client and [http://orbiter-forum.com/showthread.php?t=18431 DX9 client]. The steps presented here have been tested on Debian-stable ("jessie").  
+
This article explains how to setup a free compiler under Linux, with an assumption that Orbiter itself can be ran under Linux with Wine for testing your modules. Latest possible setup that is capable of doing it is [http://www.winehq.org Wine 1.4] and [http://sourceforge.net/apps/mediawiki/orbitervis/index.php?title=OrbiterPublicBeta Orbiter 111105], using the built-in DX7 graphical client. The steps presented here have been tested on Debian-testing. The concept is based on downloading first and running MS VC executables, wrapped by [http://www.winehq.org Wine], and fed back to a native multiplatform IDE - [http://www.codeblocks.org/ Code::Blocks]. Thanks to [http://wiki.winehq.org/winetricks/ winetricks], it's of course easy to download the VC executables, along with its IDE, and run the whole IDE through Wine, but such a setup is unstable (see for yourself).
The concept is based on downloading and running MS VC++ executables, wrapped by [http://www.winehq.org Wine], and fed back to a native multiplatform IDE - [http://www.codeblocks.org/ Code::Blocks]. Thanks to [https://wiki.winehq.org/Winetricks winetricks], it's of course easy to download the VC++ executables, along with its IDE, and run the whole VC's IDE through Wine, but such a setup is unstable.  
 
  
== Preparing Code::Blocks ==
+
== Downloading build software and Code::Blocks ==
=== Downloading build software and Code::Blocks ===
 
First, checkout and try to build C::B from source, to see if it the build succeeds. Alternatively, while the IDE builds, you may start hacking the source already.
 
 
<pre>
 
<pre>
# Build reqirements
+
sudo aptitude install subversion wine winetricks build-essential libtool automake libhunspell-dev libgamin-dev libwxgtk2.8-dev
sudo aptitude install subversion wine winetricks build-essential \
 
libtool automake libhunspell-dev libgamin-dev libwxgtk3.0-dev
 
 
 
# Codeblocks
 
 
mkdir -p ~/devel/codeblocks
 
mkdir -p ~/devel/codeblocks
 
mkdir -p ~/devel/bin
 
mkdir -p ~/devel/bin
 
cd ~/devel/codeblocks
 
cd ~/devel/codeblocks
# Checking out version 16.01 which is the latest stable version.
+
# Checking out revision 8150 which is the latest working version.
svn checkout svn://svn.code.sf.net/p/codeblocks/code/tags/16.01
+
# Check Nightly Builds page for updated revisions, available here: http://forums.codeblocks.org/index.php/board,20.0.html
 +
svn checkout -r 8150 http://svn.berlios.de/svnroot/repos/codeblocks/trunk
 
</pre>
 
</pre>
  
=== Hacking Code::Blocks ===
+
== Hacking Code::Blocks ==
The CB needs to be a bit hacked, to enable MS VC++ under Linux, which normally isn't possible. The hacking is kept to a minimum and additionally allows to use the same CB project file to compile code under Windows, using the same build targets.  
+
The CB needs to be a bit hacked, to enable MS VC++ under Linux, which normally isn't possible, because CB requires registry settings to configure the VC++. The registry is not available under Linux. The hacking is kept to a minimum and additionally allows to use the same CB project file to compile code under Windows, using the same build targets. We will do it by sacrificing one of the compilers, that are supported on Linux, in this case the Tiny C Compiler. You can use another one if you wish.
Save the following patch:
 
<pre>
 
--- compilergcc.cpp 2016-04-11 18:16:50.181091749 +0200
 
+++ compilergcc-new.cpp 2016-04-11 18:17:22.013365534 +0200
 
@@ -869,6 +869,12 @@
 
        CompilerFactory::RegisterCompiler(new CompilerIAR(wxT("8051")));
 
        CompilerFactory::RegisterCompiler(new CompilerIAR(wxT("ARM")));
 
    }
 
+    else
 
+    {
 
+    //CompilerFactory::RegisterCompiler(new CompilerMSVC);
 
+        CompilerFactory::RegisterCompiler(new CompilerMSVC8);
 
+        //CompilerFactory::RegisterCompiler(new CompilerMSVC10);
 
+    }
 
    CompilerFactory::RegisterCompiler(new CompilerICC);
 
    CompilerFactory::RegisterCompiler(new CompilerGDC);
 
    CompilerFactory::RegisterCompiler(new CompilerGNUFortran);
 
</pre>
 
Under the following full path:
 
 
<pre>
 
<pre>
~/devel/codeblocks/16.01/src/plugins/compilergcc/compilergcc-new.cpp
+
cd trunk
</pre>
+
gedit src/plugins/compilergcc/compilerMSVC8.cpp src/plugins/compilergcc/compilerTcc.cpp
And perform the actual patching:
 
<pre>
 
cd ~/devel/codeblocks/16.01/src/plugins/compilergcc/
 
patch < compilergcc-new.cpp
 
 
</pre>
 
</pre>
 +
Copy MSVC8 contents into Tcc:
 +
* constructor: replace _T("tcc") with _T("msvc8"),
 +
* copy contents of Reset() - compiler options
 +
* copy contents of LoadDefaultRegExArray() - feedback from compiler and linker to IDE
 +
* in compilerTcc.cpp, function Reset(), change cl.exe, link.exe and rc.exe to cl.sh, link.sh, and rc.sh - default executables that will be used
 +
Save and close the Tcc file.
  
=== Compiling Code::Blocks ===
+
== Compiling Code::Blocks ==
 
<pre>
 
<pre>
cd ~/devel/codeblocks/16.01
 
 
./bootstrap
 
./bootstrap
 
# New compilers need the permissive flag
 
# New compilers need the permissive flag
 
./configure --with-contrib-plugins=all --prefix=/usr CXXFLAGS=-fpermissive
 
./configure --with-contrib-plugins=all --prefix=/usr CXXFLAGS=-fpermissive
make -j2
+
make
 
sudo make install
 
sudo make install
 
</pre>
 
</pre>
  
== Preparing MS VC2005 Express and Platform SDK ==
+
== Preparing MS VC2005 Express ==
Execute the following script and take note of the comments at winetricks installation:
+
=== IDE ===
 +
Download the IDE and executables
 
<pre>
 
<pre>
#!/bin/bash
+
winetricks vc2005express
 +
</pre>
 +
Next, next, next ...
  
 +
=== Platform SDK ===
 +
This info comes from [http://appdb.winehq.org/objectManager.php?sClass=version&iId=9569 WineDB]
 +
<pre>
 
prefixName=vc2005express
 
prefixName=vc2005express
prefixDir=$HOME/.local/share/wineprefixes
+
prefixDir=$HOME/.local/share/wineprefixes/
prefix=$prefixDir/$prefixName
 
  
export WINEPREFIX=$prefix
+
for ((i=1; i<=10; i++)) ; do wget http://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.$i.cab ; done
export WINEARCH=win32
+
wget http://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.bat
 +
wget http://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/Extract.exe
 +
WINEPREFIX=$prefixDir/$prefixName wine start.exe PSDK-FULL.bat "C:\psdktemp"
 +
</pre>
 +
Wait until the previous command finishes before executing the next one:
 +
<pre>
 +
WINEPREFIX=$prefixDir/$prefixName wine "C:\psdktemp\Setup.Exe"
 +
</pre>
 +
Next, next, next ...
  
winetricks vc2005express # Deselect every component at installation
+
=== Symbolic links for ease ===
winetricks psdk2003 # Choose typical installation
+
<pre>
 +
cd $prefixDir/$prefixName/drive_c
 +
mkdir vc && cd vc
 +
ln -s ../Program\ Files/Microsoft\ Visual\ Studio\ 8/VC/bin/
 +
ln -s ../Program\ Files/Microsoft\ Visual\ Studio\ 8/VC/include/
 +
ln -s ../Program\ Files/Microsoft\ Visual\ Studio\ 8/VC/lib/
  
# Link the installed VC and SDK
+
cd $prefixDir/$prefixName/drive_c
cd $prefix/drive_c
+
mkdir psdk && cd psdk
ln -s Program\ Files/Microsoft\ Visual\ Studio\ 8/VC
+
ln -s ../Program\ Files/Microsoft\ Platform\ SDK\ for\ Windows\ XP\ SP2/Include
ln -s ../../psdk2003/drive_c/Program\ Files/Microsoft\ Platform\ SDK psdk # Symlink to psdk from other prefix
+
ln -s ../Program\ Files/Microsoft\ Platform\ SDK\ for\ Windows\ XP\ SP2/Lib
 
 
# Link an important dll, without which the toolchain fails
 
cd $prefix/drive_c/windows/system32
 
ln -s ../../Program\ Files/Microsoft\ Visual\ Studio\ 8/Common7/IDE/mspdb80.dll
 
 
</pre>
 
</pre>
  
 
== VC++ Wine wrappers ==
 
== VC++ Wine wrappers ==
Execute the following command to have a common (exchangeable) WINEPREFIX for the tool chain:
 
<pre>
 
echo "$HOME/.local/share/wineprefixes/vc2005express" > $HOME/devel/bin/wineprefix-vc.txt
 
</pre>
 
 
Create the following files:
 
Create the following files:
<pre>
 
 
~/devel/bin/cl.sh:
 
~/devel/bin/cl.sh:
</pre>
 
 
<pre>
 
<pre>
 
#!/bin/bash  
 
#!/bin/bash  
  
export WINEPREFIX=`cat $HOME/devel/bin/wineprefix-vc.txt`
+
prefixName=vc2005express
wine c:/VC/bin/cl.exe /I"c:/VC/include" /I"c:/psdk/Include" "$@"
+
prefixDir=$HOME/.local/share/wineprefixes/  
 +
WINEPREFIX=$prefixDir/$prefixName wine $prefixDir/$prefixName/drive_c/vc/bin/cl.exe /I"c:/vc/include" /I"c:/psdk/Include" $@  
 
</pre>
 
</pre>
<pre>
 
 
~/devel/bin/link.sh:
 
~/devel/bin/link.sh:
</pre>
 
 
<pre>
 
<pre>
 
#!/bin/bash
 
#!/bin/bash
  
export WINEPREFIX=`cat $HOME/devel/bin/wineprefix-vc.txt`
+
prefixName=vc2005express
wine c:/VC/bin/link.exe /LIBPATH:"c:/VC/lib" /LIBPATH:"c:/psdk/Lib" "$@"
+
prefixDir=$HOME/.local/share/wineprefixes/
 +
WINEPREFIX=$prefixDir/$prefixName wine $prefixDir/$prefixName/drive_c/vc/bin/link.exe /LIBPATH:"c:/vc/lib" /LIBPATH:"c:/psdk/Lib" $@  
 
</pre>
 
</pre>
<pre>
 
 
~/devel/bin/rc.sh:
 
~/devel/bin/rc.sh:
</pre>
 
 
<pre>
 
<pre>
 
#!/bin/bash
 
#!/bin/bash
  
export WINEPREFIX=`cat $HOME/devel/bin/wineprefix-vc.txt`
+
prefixName=vc2005express
wine c:/VC/bin/rc.exe /I"c:/VC/include" /I"c:/psdk/Include" "$@"
+
prefixDir=$HOME/.local/share/wineprefixes/
 +
WINEPREFIX=$prefixDir/$prefixName wine $prefixDir/$prefixName/drive_c/vc/bin/rc.exe $@  
 
</pre>
 
</pre>
  
Line 123: Line 106:
  
 
== Setting up Code::Blocks ==
 
== Setting up Code::Blocks ==
 +
* Download, open and use [http://enjomitchsorbit.svn.sourceforge.net/viewvc/enjomitchsorbit/launchmfd/LaunchMFD.cbp?view=log Launch MFD] project file as a template.
 
* Execute codeblocks
 
* Execute codeblocks
 
* Go to Settings->Compiler
 
* Go to Settings->Compiler
* Select Microsoft Visual C++ 2005/2008 compiler
+
* Select Tiny C Compiler
 
* Select Toolchain executables tab
 
* Select Toolchain executables tab
* In Compiler's installation directory, paste /home/<ENTER_YOUR_USERNAME>/devel/bin and modify the Program Files, to have the .sh extensions instead of the default .exe
+
* In Compiler's installation directory, paste /home/<ENTER_YOUR_USERNAME>/devel and modify accordingly
* In Search directories remove all search directories (the proper ones are already defined in our .sh wrappers)
 
* Select Build options tab and set Number of processes for parallel builds to more than 1, even if you have 1 core. This is a workaround that enables the "persistent wineserver", which greatly reduces the compilation time.
 
* Download, open and use [https://sf.net/p/enjomitchsorbit/codeHG Launch MFD] project file (available under launchmfd/LaunchMFD.cbp) as a template
 
* Download and use in your project the header file launchmfd/afxres.h. This is required for VS Express.
 
* Change orbiter2016/Orbitersdk/include/Lua to lua
 
 
* Add some sources and hit The Compile Button(TM) !
 
* Add some sources and hit The Compile Button(TM) !
  
[[Category: Articles]]
+
= Final considerations =
[[Category:Tutorials]]
+
The compilation takes a lot of time, but in theory it could be made faster by running wineserver with -p command (persistant), so that Wine doesn't spawn the server on each tool call, but even if such a server is running, Wine seems to ignore it and spawns one anyway. The command to run the wineserver on Debian is:
[[Category:Add-on tutorials]]
+
<pre>
 +
/usr/lib/i386-linux-gnu/wine/wineserver -p
 +
</pre>

Please note that all contributions to OrbiterWiki are considered to be released under the GNU Free Documentation License 1.2 (see OrbiterWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)