Difference between revisions of "Cross Compiling Plugins (Metamod:Source)"

From AlliedModders Wiki
Jump to: navigation, search
(Installing CrossTool: removed bad link)
(Installing CrossTool)
 
(6 intermediate revisions by 4 users not shown)
Line 13: Line 13:
  
  
Although the cross compiler will allow for compiling of Valves standard plugins, I do not include a Makefile or instructions on how to successfuly occomplish this.
+
Although the cross compiler will allow for compiling of Valves standard plugins, I do not include a Makefile or instructions on how to successfully accomplish this.
  
 
==Installing Cygwin==
 
==Installing Cygwin==
Line 51: Line 51:
 
If it gets renamed to 'crosstool_gcc-3.4.1.tar.tar' please rename it to 'crosstool_gcc-3.4.1.tar.gz'.
 
If it gets renamed to 'crosstool_gcc-3.4.1.tar.tar' please rename it to 'crosstool_gcc-3.4.1.tar.gz'.
 
Download Mirrors for 'crosstool_gcc.tar.gz'
 
Download Mirrors for 'crosstool_gcc.tar.gz'
*[http://files.filefront.com/crosstool_gcc_341targz/;4650645;;/fileinfo.html FileFront]
+
*[http://files.filefront.com/crosstool+gcc+341targz/;9813824;/fileinfo.html FileFront]
 
*[http://downloads.punkassfraggers.com/redirect.php?dlid=1224 PunkAssFraggers.com]
 
*[http://downloads.punkassfraggers.com/redirect.php?dlid=1224 PunkAssFraggers.com]
 +
*[http://harrisonpham.com/sourcemods/crosstool/crosstool_gcc-3.4.1.tar.gz http://harrisonpham.com] -> Thanks to el hippo
  
 
This is the most important part of the entire tutorial.
 
This is the most important part of the entire tutorial.
Line 72: Line 73:
  
 
Save it to your project's root source folder and open it with a text editor like notepad.<br>
 
Save it to your project's root source folder and open it with a text editor like notepad.<br>
Inside the Makfile I have shown examples on how your paths are translated into unix/cygwin hybrid paths.<br>
+
Inside the Makefile I have shown examples on how your paths are translated into unix/cygwin hybrid paths.<br>
 
So, before trying any compling just yet, you need to insert the paths for the following.<br>
 
So, before trying any compling just yet, you need to insert the paths for the following.<br>
  
Line 80: Line 81:
 
<b>PLUGIN</b>: The plugin filename.<br><br>
 
<b>PLUGIN</b>: The plugin filename.<br><br>
  
For the convenience of those who dont have access to a linux srcds installation, you can grab the files required at one of the mirrors below.<br>
+
For the convenience of those who don't have access to a Linux srcds installation, you can grab the files required at one of the mirrors below.<br>
 
Extract them to a new folder which will be your SRCDS path in the Makefile.<br>
 
Extract them to a new folder which will be your SRCDS path in the Makefile.<br>
 
<b>Note:</b>The bin folder must be inside the srcds folder for maximum compatibility. For example, your files end up being something like this 'C:\MyFiles\srcds_l\bin\vstdlib_i486.so'.
 
<b>Note:</b>The bin folder must be inside the srcds folder for maximum compatibility. For example, your files end up being something like this 'C:\MyFiles\srcds_l\bin\vstdlib_i486.so'.
Line 91: Line 92:
 
Now you're ready to try compiling.
 
Now you're ready to try compiling.
 
Back to the cygwin bash window, and we're now going to have to navigate to your code's location.
 
Back to the cygwin bash window, and we're now going to have to navigate to your code's location.
An exmaple path could be 'C:\MyCode\MyPlugin\' so in the bash shell we type the following:
+
An example path could be 'C:\MyCode\MyPlugin\' so in the bash shell we type the following:
  
 
   cd /cygdrive/c/MyCode/MyPlugin/
 
   cd /cygdrive/c/MyCode/MyPlugin/
Line 101: Line 102:
 
Unfortunately I cannot compile plugins for you, but there is a forum dedicated to helping you with hl2sdk coding problems.
 
Unfortunately I cannot compile plugins for you, but there is a forum dedicated to helping you with hl2sdk coding problems.
  
[http://www.sourcemod.net/forums/viewforum.php?f=24 Click here to visit the forum]
+
[http://forums.alliedmods.net/forumdisplay.php?f=75 Click here to visit the forum]
  
 
==Credits==
 
==Credits==
Line 111: Line 112:
 
Original Location: http://www.c0ld.net/index.php?inc=CrossTool
 
Original Location: http://www.c0ld.net/index.php?inc=CrossTool
  
[[Category:Documentation (SourceMM)]]
+
[[Category:Metamod:Source Development]]

Latest revision as of 16:14, 14 May 2008

Introduction

The aim of this tutorial is to allow Windows Half-Life 2 plugin coders to compile their plugins on the same machine as the windows binaries. The binaries are compatible with 99% of all linux servers and do not suffer from bulky file sizes. One of the main benefits to using this method of compiling is that your code can be left wherever you currently have it so that compile time reluctance is removed and coders can concentrate on coding the plugins instead of "How on earth am I to compile this for linux ???". All you need to get started are the base Cygwin installation, the CrossTool.tar.gz file and the makefile. Links to the latter two are included at the end of the tutorial.

This tutorial assumes the following.

  1. You currently have a plugin which you can compile on windows using MSVC.
  2. You have a copy of the HL2SDK Source Code installed on your hard drive.
  3. You have a copy of the Metamod:Source source code on your hard drive.


Although the cross compiler will allow for compiling of Valves standard plugins, I do not include a Makefile or instructions on how to successfully accomplish this.

Installing Cygwin

First, download CygWin from www.CygWin.com by clicking on "Install Now" located in the middle of the page.

Once the download finishes, run setup.exe Click 'Next' on the introduction screen.

On the second page, select 'Install from Internet'.
The following page is all user preferances, except the 'Default Text File Type' which is recommended you use 'Unix / binary'.

After clicking next, you are prompted for a CygWin temporary folder, any folder will suffice, the default is usually the better option.
The next screen's options are firewall/proxy settings, these are specific to the Computer/Network you are currently using.
Once you click next on the previous screen, the installer will download a list of mirror sites containing the CygWin binaries. Select one which you think is closest to you for a faster installation time.

Finaly, you are presented with a 'Select Packages' screen.
I *think* it should work fine without all of the dev packages.

If anyone has gotten this to work by selecting less packages, please let me know so I can remove them from this list.
Items marked in bold are extremely important.

  • binutils
  • bzip2
  • cygutils
  • gcc
  • glib
  • gzip
  • libiconv
  • make
  • zlib
  • grep

Click next and it should install the packages to the target path you specified.

Installing CrossTool

Download the CrossCompiler from one of the mirrors below to the root cygwin folder (c:\cygwin). If it gets renamed to 'crosstool_gcc-3.4.1.tar.tar' please rename it to 'crosstool_gcc-3.4.1.tar.gz'. Download Mirrors for 'crosstool_gcc.tar.gz'

This is the most important part of the entire tutorial.

Do not try and extract 'crosstool_gcc-3.4.1.tar.gz' using any Windows Archiving utility ! They do not extract the files correctly and if you don't get errors during the extraction, you will while trying to compile ! Once the download is complete, run cygwin by navigating to the cygwin root folder, and double clicking on 'cygwin.bat'. Type the following two commands in order into the cygwin bash shell followed by the enter key:

 cd /
 tar -xzf crosstool_gcc-3.4.1.tar.gz

This will start extracting the tar file to the '<cygroot>/opt' folder on your hard drive. And thats it, now you have the pre-compiled GCC 3.4.1 (Thanks LDuke) installed on your computer you can compile server plugins for both regular and SourceMM flavours with ease and compatibility with Valves GCC 3.4.1 requirements.

Compiling Plugins

Download the Makefile by clicking on this link.

Save it to your project's root source folder and open it with a text editor like notepad.
Inside the Makefile I have shown examples on how your paths are translated into unix/cygwin hybrid paths.
So, before trying any compling just yet, you need to insert the paths for the following.

HL2SDK: The path to where your HL2SDK files are located.
SMM_ROOT: The path to where you extracted the contents of the SourceMM package
SRCDS: The path to the linux SRCDS binaries.
PLUGIN: The plugin filename.

For the convenience of those who don't have access to a Linux srcds installation, you can grab the files required at one of the mirrors below.
Extract them to a new folder which will be your SRCDS path in the Makefile.
Note:The bin folder must be inside the srcds folder for maximum compatibility. For example, your files end up being something like this 'C:\MyFiles\srcds_l\bin\vstdlib_i486.so'.

So, in your Makefile, SRCDS would be '/cygdrive/c/MyFiles/srcds_l'

Download Mirrors for 'srcds_l_binaries.zip'

Now you're ready to try compiling. Back to the cygwin bash window, and we're now going to have to navigate to your code's location. An example path could be 'C:\MyCode\MyPlugin\' so in the bash shell we type the following:

 cd /cygdrive/c/MyCode/MyPlugin/
 make

If all your paths are set correctly, it should start compiling the plugin. Ignore all the warnings in the HL2SDK, they are harmless. What you should be looking out for are errors and warnings located inside your own code. Unfortunately I cannot compile plugins for you, but there is a forum dedicated to helping you with hl2sdk coding problems.

Click here to visit the forum

Credits

  • Tutorial by: Jason "c0ldfyr3" Croghan
  • Cross Compiler compiled by: L. Duke
  • Makefile originally written by: David "BAILOPAN" Anderson
  • Converted to Wiki by: James "sslice" Gray

Original Location: http://www.c0ld.net/index.php?inc=CrossTool