Editing Free Compiler Setup
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | This page documents the travails and heartache necessary to get the | + | This page documents the travails and heartache necessary to get the MSVC++ 2005 Express Edition to compile Orbiter projects. |
− | + | = Get the Compiler = | |
− | + | Go to the [http://msdn.microsoft.com/vstudio/express/visualc/download/ Microsoft download center] and get the compiler. | |
− | |||
− | |||
− | Go to the [ | ||
Tell the program you are agreeing to its pernicious license agreement, but do it with your fingers crossed. | Tell the program you are agreeing to its pernicious license agreement, but do it with your fingers crossed. | ||
− | + | Get the Graphical IDE, but not MSDN or SQL stuff. | |
− | + | = Get Orbiter and the SDK = | |
− | Get Orbiter from [ | + | Get Orbiter and the OrbiterSDK from [http://www.orbitersim.com/ Orbitersim.com] and unpack it. You need at least 4 files: |
− | + | #Orbiter Base (050116) | |
− | + | #Orbiter SDK (050116) | |
− | + | #Orbiter Base Patch (050216) | |
− | + | #Orbiter SDK Patch (050216) | |
− | |||
− | |||
− | #Orbiter Base ( | ||
− | #Orbiter SDK ( | ||
Unpack all these files into the same folder, in order. A good choice is <tt>C:\Orbiter</tt>. This document assumes you use this path, from now on. | Unpack all these files into the same folder, in order. A good choice is <tt>C:\Orbiter</tt>. This document assumes you use this path, from now on. | ||
− | When installing the patches, it will | + | When installing the patches, it will if it is ok to replace a file. Say ''yes to all''. |
− | + | = Get the Windows SDK = | |
You need the SDK to get <tt>windows.h</tt> and its associated files. | You need the SDK to get <tt>windows.h</tt> and its associated files. | ||
− | + | Go to [http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en here] to get the Windows Platform SDK. It says it is the Windows 2003 Server SDK but it includes what we want. Run the installer and uncheck everything but what is shown below. | |
− | |||
− | Run the installer and uncheck everything but what is shown below. | ||
[[Image:SDKInstall1.png]] | [[Image:SDKInstall1.png]] | ||
− | + | = Setting up a project = | |
− | VC++ 2003 files are not perfectly compatible with VC++ 2005, and the non-free version is not perfectly compatible with the free version. | + | VC++ 2003 files are not perfectly compatible with VC++ 2005, and the non-free version is not perfectly compatible with the free version. There are several changes that you need to make to the project to get it to compile. Fortunately, they are small, and the same for all projects. |
We will modify the ShuttlePB project to work with the VC++2005. Start VC++, and open the project file <tt>OrbiterSDK\samples\ShuttlePB\ShuttlePB.dsw</tt>. | We will modify the ShuttlePB project to work with the VC++2005. Start VC++, and open the project file <tt>OrbiterSDK\samples\ShuttlePB\ShuttlePB.dsw</tt>. | ||
− | + | == Configuration == | |
At the top, immediately under the menu bar, change the Configuration to ''Release''. | At the top, immediately under the menu bar, change the Configuration to ''Release''. | ||
Line 51: | Line 42: | ||
[[Image:SDKInstall2.png]] | [[Image:SDKInstall2.png]] | ||
− | + | == Include path == | |
− | + | Add the SDK include path for both the Platform SDK and the Orbiter SDK to the project include path. The Platform SDK installs itself by default to <tt>C:\Program Files\Microsoft Platform SDK</tt> so add the path <tt>C:\Program Files\Microsoft Platform SDK\Include</tt>. Orbiter can be installed anywhere, but if you unpacked it to <tt>C:\Orbiter</tt>, the correct path is <tt>C:\Orbiter\Orbitersdk\include</tt>. Or, you can have it be a relative path, like <tt>..\..\include</tt> (This number of ..\ is correct for ShuttlePB, check for the right number for anyplace else) | |
[[Image:SDKInstall3.png]] | [[Image:SDKInstall3.png]] | ||
− | + | == Library path == | |
− | Add the SDK library path for both the Platform SDK and the Orbiter SDK to the linker library path. The Platform SDK path default is <tt>C:\Program Files\Microsoft Platform SDK\lib</tt>. The Orbiter SDK default is <tt>C:\Orbiter\Orbitersdk\lib</tt> | + | Add the SDK library path for both the Platform SDK and the Orbiter SDK to the linker library path. The Platform SDK path default is <tt>C:\Program Files\Microsoft Platform SDK\lib</tt>. The Orbiter SDK default is <tt>C:\Orbiter\Orbitersdk\lib</tt> |
[[Image:SDKInstall5.png]] | [[Image:SDKInstall5.png]] | ||
− | + | == C++ language change == | |
− | |||
− | |||
− | + | MSVC++ 2005 uses a slightly different standard of C++ than Orbiter is used to. Fortunately, this is a very slight change. | |
− | + | First, load OrbiterAPI.h and change the reference to <tt><fstream.h></tt> to <tt><fstream></tt> | |
− | + | If you were to build the project now, it would break on line 43 of <tt>ShuttlePB.cpp</tt>. Simply change the function as shown. | |
// Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi | // Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi | ||
Line 90: | Line 79: | ||
} | } | ||
− | The exact problem here is that in | + | The exact problem here is that in VC++2003, the variable <tt>i</tt> in the one-line for statement <tt>for(int i=0</tt>... has scope over its entire block, in this case the entire function. In VC++2005, <tt>i</tt> only has scope over the for statement. Other projects may break in the compile phase for similar reasons. |
− | + | There is an option in the project compiler settings window which changes this particular standard, but I happen to think that the code change makes the code clearer and more readable. I have not tested if the compiler setting works. | |
− | + | == Adding and Removing libraries == | |
− | + | Compiling a vessel requires the Windows SDK library <tt>kernel32.lib</tt>. This one is always compiled into Win32 projects by default. Compiling MFDs also require the Windows SDK libraries <tt>user32.lib</tt> and <tt>gdi32.lib</tt>. These are not compiled in by default, so you have to add them to the "Additional Dependencies" line. | |
− | + | Believe it or not, the project demands weird stuff like ODBC support by default. Why would a vessel ever need to use a database? This is easy to remove. Just take the odbc libraries out of the "Additional Dependencies" line. Also, by default, the project tries to link against the library <tt>msvcirt.lib</tt> which is not included in the free VC++2005 download, or the SDK download. We can easily get rid of this also. Add this library to the "Ignore specific library" line. | |
− | |||
− | |||
Edit the project properties, and make the changes as shown below: | Edit the project properties, and make the changes as shown below: | ||
Line 106: | Line 93: | ||
[[Image:SDKInstall4.png]] | [[Image:SDKInstall4.png]] | ||
− | + | = Compiling the addon = | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Use the menu option Build/Build ShuttlePB to compile. It should now compile cleanly, no errors or warnings. The DLL will be in <tt>C:\Orbiter\Modules\ShuttlePB.dll</tt>. If you are making an MFD or plugin, you will want those to compile into the <tt>C:\Orbiter\Modules\Plugin</tt> folder. If you go look up this module, it should have the current time, and be accompanied by a .exp and a .lib file, both of which have the current date on them. Load any scenario which uses ShuttlePB and fly it normally. | Use the menu option Build/Build ShuttlePB to compile. It should now compile cleanly, no errors or warnings. The DLL will be in <tt>C:\Orbiter\Modules\ShuttlePB.dll</tt>. If you are making an MFD or plugin, you will want those to compile into the <tt>C:\Orbiter\Modules\Plugin</tt> folder. If you go look up this module, it should have the current time, and be accompanied by a .exp and a .lib file, both of which have the current date on them. Load any scenario which uses ShuttlePB and fly it normally. | ||
− | + | = To Do = | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | *<strike>Check if this compiles MFDs</strike>'''With the addition of <tt>user32.lib</tt> and <tt>gdi32.lib</tt> as described above, this works.''' | |
− | + | *Check if this compiles vessels with panels |