Difference between revisions of "Free Compiler Setup Under Linux"
(Removed Final considerations) |
|||
Line 139: | Line 139: | ||
* 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. | ||
* Add some sources and hit The Compile Button(TM) ! | * Add some sources and hit The Compile Button(TM) ! | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:Tutorials]][[Category:Addon tutorials]] | [[Category:Tutorials]][[Category:Addon tutorials]] |
Revision as of 15:04, 12 April 2016
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 Wine 1.6.2 and ORBITER 2010-P1, using the built-in DX7 graphical client and DX9 client. The steps presented here have been tested on Debian-stable ("jessie"), with Nouveau graphics drivers. 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 IDE through Wine, but such a setup is unstable.
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.
sudo aptitude install subversion wine winetricks build-essential \ libtool automake libhunspell-dev libgamin-dev libwxgtk3.0-dev mkdir -p ~/devel/codeblocks mkdir -p ~/devel/bin cd ~/devel/codeblocks # Checking out version which is the latest working version. svn checkout svn://svn.code.sf.net/p/codeblocks/code/tags/16.01
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. 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:
patch < ~/devel/codeblocks/16.01/src/plugins/compilergcc/compilergcc-new.cpp
Compiling Code::Blocks
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
IDE
Download the IDE and executables
winetricks vc2005express
Select installation of only the first option (the IDE)
Platform SDK
This info comes from WineDB
prefixName=vc2005express prefixDir=$HOME/.local/share/wineprefixes/ 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 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"
Wait until the previous command finishes before executing the next one:
WINEPREFIX=$prefixDir/$prefixName wine "C:\psdktemp\Setup.Exe"
Install only the "Configuration Options" and "Microsoft Windows Core SDK". Be sure to check if the PSDK installed itself into $HOME/.local/share/wineprefixes/vc2005express/Program Files. If not, (could be $HOME/.local/share/wineprefixes/vc2005express/INSTALLLOCATION), move it straight to $HOME/.local/share/wineprefixes/vc2005express/psdk
Symbolic links for ease
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/ # Ommit this step, if the PSDK was already to the psdk dir cd $prefixDir/$prefixName/drive_c mkdir psdk && cd psdk ln -s ../Program\ Files/Microsoft\ Platform\ SDK\ for\ Windows\ XP\ SP2/Include ln -s ../Program\ Files/Microsoft\ Platform\ SDK\ for\ Windows\ XP\ SP2/Lib # Link the installation links to main .wine dir cd $HOME/.wine/drive_c ln -s $prefixDir/$prefixName/drive_c/vc ln -s $prefixDir/$prefixName/drive_c/psdk
VC++ Wine wrappers
For some reason the WINEPREFIX didn't work on my box, therefore I needed to use the global .wine installation. Create the following files:
~/devel/bin/cl.sh:
#!/bin/bash wine $HOME/.wine/drive_c/vc/bin/cl.exe /I"c:/vc/include" /I"c:/psdk/Include" $@
~/devel/bin/link.sh:
#!/bin/bash wine $HOME/.wine/drive_c/vc/bin/link.exe /LIBPATH:"c:/vc/lib" /LIBPATH:"c:/psdk/Lib" $@
~/devel/bin/rc.sh:
#!/bin/bash wine $HOME/.wine/drive_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
- 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.
- Add some sources and hit The Compile Button(TM) !