Difference between revisions of "Cross Compiling Plugins (Metamod:Source)"
(→Installing CrossTool) |
|||
(20 intermediate revisions by 5 users not shown) | |||
Line 4: | Line 4: | ||
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 ???". | 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. | 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. | ||
+ | <OL> | ||
<LI>You currently have a plugin which you can compile on windows using MSVC. | <LI>You currently have a plugin which you can compile on windows using MSVC. | ||
<LI>You have a copy of the HL2SDK Source Code installed on your hard drive. | <LI>You have a copy of the HL2SDK Source Code installed on your hard drive. | ||
Line 10: | Line 12: | ||
</OL> | </OL> | ||
− | Although the cross compiler will allow for compiling of Valves standard plugins, I do not include a Makefile or instructions on how to | + | |
+ | 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 18: | Line 21: | ||
Click 'Next' on the introduction screen. | Click 'Next' on the introduction screen. | ||
− | On the second page, select 'Install from Internet'. | + | On the second page, select 'Install from Internet'.<br> |
− | The following page is all user preferances, except the 'Default Text File Type' which is recommended you use 'Unix / binary'. | + | The following page is all user preferances, except the 'Default Text File Type' which is recommended you use 'Unix / binary'.<br><br> |
− | After clicking next, you are prompted for a CygWin temporary folder, any folder will suffice, the default is usually the better option. | + | After clicking next, you are prompted for a CygWin temporary folder, any folder will suffice, the default is usually the better option.<br> |
− | The next screen's options are firewall/proxy settings, these are specific to the Computer/Network you are currently using. | + | The next screen's options are firewall/proxy settings, these are specific to the Computer/Network you are currently using.<br> |
− | 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. | + | 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.<br><br> |
− | Finaly, you are presented with a 'Select Packages' screen. | + | Finaly, you are presented with a 'Select Packages' screen.<br> |
− | I *think* it should work fine without all of the dev packages. | + | I *think* it should work fine without all of the dev packages.<br><br> |
− | If anyone has gotten this to work by selecting less packages, please let me know so I can remove them from this list. | + | If anyone has gotten this to work by selecting less packages, please let me know so I can remove them from this list.<br> |
− | Items marked in bold are extremely important. | + | Items marked in bold are extremely important.<br><br> |
*binutils | *binutils | ||
Line 44: | Line 47: | ||
<p> | <p> | ||
− | ==Installing | + | ==Installing CrossTool== |
Download the CrossCompiler from one of the mirrors below to the root cygwin folder <i>(c:\cygwin)</i>. | Download the CrossCompiler from one of the mirrors below to the root cygwin folder <i>(c:\cygwin)</i>. | ||
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' | |
− | + | *[http://files.filefront.com/crosstool+gcc+341targz/;9813824;/fileinfo.html FileFront] | |
− | + | *[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 58: | Line 61: | ||
Once the download is complete, run cygwin by navigating to the cygwin root folder, and double clicking on <i>'cygwin.bat'</i>. | Once the download is complete, run cygwin by navigating to the cygwin root folder, and double clicking on <i>'cygwin.bat'</i>. | ||
Type the following two commands in order into the cygwin bash shell followed by the enter key: | 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. | 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 [http://www.lduke.com (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. | And thats it, now you have the pre-compiled GCC 3.4.1 [http://www.lduke.com (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. | ||
<p> | <p> | ||
+ | |||
==Compiling Plugins== | ==Compiling Plugins== | ||
Download the Makefile by clicking on [http://www.c0ld.net/Tutorials/CrossTool/Makefile this link.] | Download the Makefile by clicking on [http://www.c0ld.net/Tutorials/CrossTool/Makefile this link.] | ||
− | Save it to your project's root source folder and open it with a text editor like notepad. | + | Save it to your project's root source folder and open it with a text editor like notepad.<br> |
− | Inside the | + | 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. | + | So, before trying any compling just yet, you need to insert the paths for the following.<br> |
− | <b>HL2SDK</b>: The path to where your HL2SDK files are located. | + | |
− | <b>SMM_ROOT</b>: The path to where you extracted the contents of the [http://www.sourcemm.net/ SourceMM package] | + | <b>HL2SDK</b>: The path to where your HL2SDK files are located.<br> |
+ | <b>SMM_ROOT</b>: The path to where you extracted the contents of the [http://www.sourcemm.net/ SourceMM package]<br> | ||
+ | <b>SRCDS</b>: The path to the linux SRCDS binaries.<br> | ||
+ | <b>PLUGIN</b>: The plugin filename.<br><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> | |
− | For the convenience of those who | ||
− | Extract them to a new folder which will be your SRCDS path in the Makefile. | ||
<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'. | ||
So, in your Makefile, SRCDS would be '/cygdrive/c/MyFiles/srcds_l' | So, in your Makefile, SRCDS would be '/cygdrive/c/MyFiles/srcds_l' | ||
− | + | ||
− | + | Download Mirrors for 'srcds_l_binaries.zip' | |
− | + | *[http://files.filefront.com/srcds_l_binarieszip/;4651213;;/fileinfo.html FileFront Mirror] | |
− | + | *[http://rapidshare.de/files/11597264/srcds_l_binaries.zip.html RapidShare.de Mirror] | |
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 | + | 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 96: | 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:// | + | [http://forums.alliedmods.net/forumdisplay.php?f=75 Click here to visit the forum] |
==Credits== | ==Credits== | ||
*Tutorial by: Jason "c0ldfyr3" Croghan | *Tutorial by: Jason "c0ldfyr3" Croghan | ||
− | |||
*Cross Compiler compiled by: L. Duke | *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 | Original Location: http://www.c0ld.net/index.php?inc=CrossTool | ||
+ | |||
+ | [[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.
- You currently have a plugin which you can compile on windows using MSVC.
- You have a copy of the HL2SDK Source Code installed on your hard drive.
- 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'
- FileFront
- PunkAssFraggers.com
- http://harrisonpham.com -> Thanks to el hippo
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.
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