Compiler Setup
From OPU Wiki
This page will tell you how to get started writing OP2 missions with the free Microsoft Visual C++ Toolkit 2003 and CodeBlocks IDE.
| Table of contents |
System Requirements
- A PC running Windows. You shouldn't need a top-of-the-line PC. Chances are, if it can run Outpost 2, you'll probably be able to install and use the compiler and tools.
- Around 120 MB of hard drive space to install the compiler and tools.
- If you have a really slow Internet connection, you may want to download using a faster connection. There are approximately 18 MB of files to download.
Note: If you already have a copy of Microsoft Visual C++ 5, 6, or .NET installed, you'll save 6 MB of downloading and about 60 MB of hard drive space.
Files to Download
- The Microsoft Visual C++ Toolkit 2003 compiler.
We have provided the .MSI file for the Toolkit, it can be downloaded from:
toolkit-base.msi (7 MB) (http://www.outpost-universe.net/files/coding/toolkit-base.msi)
(You can download the full package from Microsoft's website if you wish, however it is 30 MB since it includes the .NET Framework Runtime, which you don't need (and shouldn't use) for OP2 coding. This 7 MB download is JUST the compiler portion of Microsoft's download, and is enough for us).
- CodeBlocks IDE. We used version 1.0rc2. You can download it from:
codeblocks-1.0rc2.exe (3.8 MB) (http://www.outpost-universe.net/files/coding/codeblocks-1.0rc2.exe)
(You may wish to download from www.codeblocks.org to get the latest version. Get the CodeBlocks IDE, without compiler).
- If you don't have MSVC++ 5, 6, or .NET installed, you'll need the Microsoft Platform SDK headers and libraries. The minimum ones required for OP2 coding can be downloaded from:
platformsdk-headers.rar (5.8 MB) (http://www.outpost-universe.net/files/coding/platformsdk-headers.rar)
(If you want the complete, up-to-date Platform SDK, go download it from msdn.microsoft.com. However, be warned that it's close to a 400 MB download, and isn't required for simple OP2 coding). If you do have MSVC++ 5, 6, or .NET installed; you don't need this file; we will use the headers and libraries supplied with MSVC already. (Well, you can download it if you really WANT to; it's just unnecessary and a waste of space).
- Lastly, you'll need the Outpost 2 SDK for CodeBlocks, which allows you to create Outpost 2 missions. Download from:
op2_cbsdk.rar (49 KB) (http://www.outpost-universe.net/files/coding/op2_cbsdk.rar)
Installing the Compiler and IDE
Double click on the toolkit-base.msi file (or the Toolkit file you downloaded from Microsoft if you went that route. In that case, wait a few minutes while the program installs the useless .NET Framework first). Install the program to any directory of your choice. (Remember the directory you installed to; you'll probably want to remember it later).
If an error appears about "The InstallScript engine is missing from this machine" or something similar when you try to install, download IsScript9.zip (647 KB (http://www.outpost-universe.net/files/other/IsScript9.zip) and double click the .msi file inside of the zip, and install it. Then re-run the toolkit setup file again.
Next, double click the Codeblocks setup file. When you get to the screen to select components, you could uncheck components that we won't need / use, such as the Class wizard, GDB Debugger, Plugin wizard, To-Do list, and Default MIME handler, unless you want these plugins. (It doesn't hurt if you do have them, but you probably won't use them). You may also want to uncheck the "Contributed plugins".
After installation, it will pop up a message about compilers: just click Next. At the end of the installation, leave the checkbox selected to launch CodeBlocks.
Configuring CodeBlocks
The first time CodeBlocks runs, a dialog may pop up asking if you want to make CodeBlocks the default editor for C/C++ files. Unless you have another C/C++ compiler installed on your system, such as MSVC, you should click Yes.
Next, a dialog will pop up labeled "Compilers auto-detection." Microsoft Visual C++ Toolkit 2003 should read "detected" next to it. Click it, then press Set as default to make it your default compiler. Click Close to continue.
The main CodeBlocks interface will load. Disable the pop up tips if you want. Now go to the Settings > Environment menu. Here, you will set a few settings that should make coding a little easier.
Click the View tab and check the box labeled "Auto hide message pane". This gives you more room to work with when you are writing code, and only pops up the error messages when compiling, or when errors actually occur.
Select the "Blank workspace" option near the top. This ensures that projects are not already open when CodeBlocks is started. You may want to click the "16 x 16 - small" option as well; this makes the toolbar icons smaller and gives you more room.
Next, go to Settings > Compiler. The "selected compiler" dropdown should read Microsoft Visual C++ Toolkit 2003.
Click the Linker tab, and press the Add button below the "Link libraries" list. Add the following names into the list: (just enter as is into the entry box, don't enter a path)
- kernel32.lib
- user32.lib
- gdi32.lib
- advapi32.lib
Switch to the Directories tab, and leave the dialog open. (You'll need to enter some things here shortly).
Extracting the Platform SDK Files
If you have MSVC++ 5, 6, or .NET installed, or you installed the whole Platform SDK, skip down to the "If you have MSVC / Platform SDK" section below.
Extract the platformsdk-headers.rar file (you'll need WinRAR (http://www.rarlab.com)) to the location you installed the Toolkit. (Usually C:\Program Files\Microsoft Visual C++ Toolkit 2003)
Be warned: This will extract 50-60 MB of files to your harddrive
If asked to overwrite any files, select No to all. Proceed to the next section to finish the setup.
If you have MSVC / Platform SDK: On the Directories tab, click the smaller Compiler tab. Add your \Include directory to the list. (For example C:\Program Files\Microsoft Visual C++\Include) Switch to the lower Linker tab and add your \Lib folder to the list. (Example: C:\Program Files\Microsoft Visual C++\Lib)
Proceed to the next section to install the OP2 SDK files.
Installing the OP2 SDK
Unpack the op2_cbsdk.rar file you downloaded to any folder. Go into CodeBlocks, to the Settings > Compiler > Directories tab again. Click the lower Compiler tab, and add the \Include folder from the OP2 SDK that you just unpacked to the list. Next, click the lower Linker tab, and add the \Lib folder from the folder you just unpacked. Click OK in the dialog box, and exit CodeBlocks.
Go into the folder you just unpacked, and open the \CB_Templates folder. This folder contains the project templates for use in CodeBlocks.
Copy the contents of the folder (not the CB_Templates folder itself, but the share folder inside of it) to the CodeBlocks installation folder. (Usually C:\Program Files\CodeBlocks). Click Yes to All if it asks about overwriting files with the same names here.
Restart CodeBlocks. Go to File > New Project and select Outpost 2 from the drop down.
There should be two OP2 Mission templates. Select the Hooville-based one and press Create. (Leave "Do not create any files" unchecked).
The program will ask where you want to save the project. Create a new folder for it and save into that folder. (Each project, for organizational reasons, should be in its own folder)
The editor will load. To begin editing files, expand the OP2Script at the lower left of the CodeBlocks window, then the Sources folder. Double click Main.cpp.
The main source code file will load. Don't edit anything yet however, since we need to test that the compiler is working. Click the blue gear on the main toolbar (labeled Compile if you hover the mouse over) or go to Compile > Compile on the menu. A white pane should show some text in the bottom of the screen as the DLL compiles. It should compile fine, and say "0 errors, 0 warnings" in dark blue.
If it didn't compile correctly, check that you got all the settings correct in Settings > Compiler (the Linker tab and the Directories tab as shown above).
Now you're on your way to creating missions!
When you compile, an OP2Script.dll file will be compiled in the same folder that you saved the project in. Rename this file appropriately (e.g. starting with t for Tutorials, c for Colony Games, ml for Last one Standing, etc), and copy to your OP2 folder to test. Also note, if your compile contains errors, an error pane will pop up at the bottom. Double click any error in the list to open the file with the error and highlight the line where the error was found.
When you want to close an open file in the project to get it out of the way, right click it on the Opened Files pane in the upper left, and select Close. Similarily, you can make any file the current file by double clicking.
When you want to close one project and load another, use File > Close project to close the existing one. Then use File > Open to load the .cbp file for whichever project you are starting to edit.
Good luck with OP2 mission coding!
Categories: Outpost 2 | Coding | How To
