Difference between revisions of "Free Compiler Setup Under Linux"
(Added category.) |
|||
(19 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | This article explains how to setup a free compiler under Linux, under assumption, that Orbiter itself can be ran under Linux | + | 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"). |
− | 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 [ | + | 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 == | == Preparing Code::Blocks == | ||
Line 14: | Line 14: | ||
mkdir -p ~/devel/bin | mkdir -p ~/devel/bin | ||
cd ~/devel/codeblocks | cd ~/devel/codeblocks | ||
− | # Checking out version 16.01 which is the latest | + | # Checking out version 16.01 which is the latest stable version. |
svn checkout svn://svn.code.sf.net/p/codeblocks/code/tags/16.01 | svn checkout svn://svn.code.sf.net/p/codeblocks/code/tags/16.01 | ||
</pre> | </pre> | ||
Line 44: | Line 44: | ||
And perform the actual patching: | And perform the actual patching: | ||
<pre> | <pre> | ||
− | + | cd ~/devel/codeblocks/16.01/src/plugins/compilergcc/ | |
+ | patch < compilergcc-new.cpp | ||
</pre> | </pre> | ||
Line 57: | Line 58: | ||
</pre> | </pre> | ||
− | == Preparing MS VC2005 Express == | + | == Preparing MS VC2005 Express and Platform SDK == |
− | + | Execute the following script and take note of the comments at winetricks installation: | |
− | |||
<pre> | <pre> | ||
− | + | #!/bin/bash | |
− | |||
− | |||
− | |||
− | |||
− | |||
prefixName=vc2005express | prefixName=vc2005express | ||
− | prefixDir=$HOME/.local/share/wineprefixes/ | + | prefixDir=$HOME/.local/share/wineprefixes |
+ | prefix=$prefixDir/$prefixName | ||
− | + | export WINEPREFIX=$prefix | |
− | + | export WINEARCH=win32 | |
− | |||
− | WINEPREFIX=$ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | winetricks vc2005express # Deselect every component at installation | |
− | + | winetricks psdk2003 # Choose typical installation | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | # | + | # Link the installed VC and SDK |
− | cd $ | + | cd $prefix/drive_c |
− | + | ln -s Program\ Files/Microsoft\ Visual\ Studio\ 8/VC | |
− | ln -s | + | ln -s ../../psdk2003/drive_c/Program\ Files/Microsoft\ Platform\ SDK psdk # Symlink to psdk from other prefix |
− | ln -s ../Program\ Files/Microsoft\ Platform\ SDK | ||
− | # Link the | + | # Link an important dll, without which the toolchain fails |
− | cd $ | + | cd $prefix/drive_c/windows/system32 |
− | ln -s | + | 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> | <pre> | ||
Line 110: | Line 94: | ||
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
− | + | ||
+ | export WINEPREFIX=`cat $HOME/devel/bin/wineprefix-vc.txt` | ||
+ | wine c:/VC/bin/cl.exe /I"c:/VC/include" /I"c:/psdk/Include" "$@" | ||
</pre> | </pre> | ||
<pre> | <pre> | ||
Line 117: | Line 103: | ||
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
− | + | ||
+ | export WINEPREFIX=`cat $HOME/devel/bin/wineprefix-vc.txt` | ||
+ | wine c:/VC/bin/link.exe /LIBPATH:"c:/VC/lib" /LIBPATH:"c:/psdk/Lib" "$@" | ||
</pre> | </pre> | ||
<pre> | <pre> | ||
Line 124: | Line 112: | ||
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
− | + | ||
+ | export WINEPREFIX=`cat $HOME/devel/bin/wineprefix-vc.txt` | ||
+ | wine c:/VC/bin/rc.exe /I"c:/VC/include" /I"c:/psdk/Include" "$@" | ||
</pre> | </pre> | ||
Line 142: | Line 132: | ||
* Download, open and use [https://sf.net/p/enjomitchsorbit/codeHG Launch MFD] project file (available under launchmfd/LaunchMFD.cbp) as a template | * 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. | * 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:Tutorials]][[Category: | + | [[Category: Articles]] |
+ | [[Category:Tutorials]] | ||
+ | [[Category:Add-on tutorials]] |
Latest revision as of 10:39, 14 October 2022
This article explains how to setup a free compiler, MS VC++, under Linux through Wine, under assumption, that Orbiter itself can be ran under Linux through Wine for testing your modules. Latest possible setup that is capable of doing it is Wine 1.6.2 and Orbiter 2016, using the built-in DX7 graphical client and DX9 client. The steps presented here have been tested on Debian-stable ("jessie"). The concept is based on downloading and running MS VC++ executables, wrapped by Wine, and fed back to a native multiplatform IDE - Code::Blocks. Thanks to 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[edit]
Downloading build software and Code::Blocks[edit]
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.
# Build reqirements 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/bin cd ~/devel/codeblocks # Checking out version 16.01 which is the latest stable version. svn checkout svn://svn.code.sf.net/p/codeblocks/code/tags/16.01
Hacking Code::Blocks[edit]
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. Save the following patch:
--- 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);
Under the following full path:
~/devel/codeblocks/16.01/src/plugins/compilergcc/compilergcc-new.cpp
And perform the actual patching:
cd ~/devel/codeblocks/16.01/src/plugins/compilergcc/ patch < compilergcc-new.cpp
Compiling Code::Blocks[edit]
cd ~/devel/codeblocks/16.01 ./bootstrap # New compilers need the permissive flag ./configure --with-contrib-plugins=all --prefix=/usr CXXFLAGS=-fpermissive make -j2 sudo make install
Preparing MS VC2005 Express and Platform SDK[edit]
Execute the following script and take note of the comments at winetricks installation:
#!/bin/bash prefixName=vc2005express prefixDir=$HOME/.local/share/wineprefixes prefix=$prefixDir/$prefixName export WINEPREFIX=$prefix export WINEARCH=win32 winetricks vc2005express # Deselect every component at installation winetricks psdk2003 # Choose typical installation # Link the installed VC and SDK cd $prefix/drive_c ln -s Program\ Files/Microsoft\ Visual\ Studio\ 8/VC ln -s ../../psdk2003/drive_c/Program\ Files/Microsoft\ Platform\ SDK psdk # Symlink to psdk from other prefix # 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
VC++ Wine wrappers[edit]
Execute the following command to have a common (exchangeable) WINEPREFIX for the tool chain:
echo "$HOME/.local/share/wineprefixes/vc2005express" > $HOME/devel/bin/wineprefix-vc.txt
Create the following files:
~/devel/bin/cl.sh:
#!/bin/bash export WINEPREFIX=`cat $HOME/devel/bin/wineprefix-vc.txt` wine c:/VC/bin/cl.exe /I"c:/VC/include" /I"c:/psdk/Include" "$@"
~/devel/bin/link.sh:
#!/bin/bash export WINEPREFIX=`cat $HOME/devel/bin/wineprefix-vc.txt` wine c:/VC/bin/link.exe /LIBPATH:"c:/VC/lib" /LIBPATH:"c:/psdk/Lib" "$@"
~/devel/bin/rc.sh:
#!/bin/bash export WINEPREFIX=`cat $HOME/devel/bin/wineprefix-vc.txt` wine c:/VC/bin/rc.exe /I"c:/VC/include" /I"c:/psdk/Include" "$@"
and make them executable:
chmod +x ~/devel/bin/*
Setting up Code::Blocks[edit]
- Execute codeblocks
- Go to Settings->Compiler
- Select Microsoft Visual C++ 2005/2008 compiler
- 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 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 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) !