Compiler setup: VS 2015 - Orbiter 2010

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
225
Reaction score
104
Points
58
Location
Lehi, Utah
This is a 'bare metal' to 'debugging' walk through based on Visual Studio 2015 Community edition targeting Orbiter 2010. I developed this based on a clean install of Windows 10 in Hyper-V.

- Find the Visual Studio Community 2015 installer (google). The initial download is a small installer that will then pull down the components you request.

- In the installer open the 'Programming Languages' tab and select Visual C++. Under Visual C++ select 'Common Tools for C++'. You can un-select Windows Foundation Classes and Windows XP Support. Of course, you can install these if you want, but they are not required. Let the installer do its thing.

- Download the Orbiter 2010 zip file without the extra textures and expand it into 'C:\Orbiter'. This will be our orbiter directory.

- Run Orbiter so that it does its initial install.

- Run Orbiter again and open the Delta-Glider Brighton Beach scenario. We do this to verify that our installation of Orbiter is working. We will use this scenario later in testing. There are only a few things more frustrating then spending hours trying to get your debugger to work, only to learn your Orbiter install is broken in some way.

- Start Visual Studio and open the ShuttlePB sample solution: C:\Orbiter\Orbitersdk\samples\ShuttlePB\ShuttlePB.sln. You will be prompted to do a one-way conversion. Say yes and allow Visual Studio to convert the ShuttlePB project in place.

- Converting the ShuttlePB project is important. It also converts the property sheets so that they are compatible with VS 2015. You will also reference these property sheets from your projects.

- Now we need to point the property sheets to our Orbiter directory (C:\Orbiter). In Visual Studio, select 'View\Other Windows\Property Manager'. The Property Manager tab should now show up in the same window as the Solution Explorer.

- In the Property Manager expand ShuttlePB->Debug | Win32 -> Orbiter vessel -> orbiter_vs2005 -> orbiterroot. Right click on 'orbiterroot' and select Properties.

- You should see the 'orbiterroot Property Pages' window. On the left, select 'User Macros'. When you do, on the right you will see 'OrbiterDir'. Change this to our Orbiter install folder; 'C:\Orbiter' (without quotes) and close the property page.

- Now ShuttlePB should build. Press Ctrl-Shift-B to build.

When in doubt about your environment, get ShuttlePB to build. Its simple and should build easily.

Now we will try to debug to see that everything is working.

- Click the 'Solution Explorer' tab and open the ShuttlePB.cpp file. Put your cursor on the 'SetSize (PB_SIZE);' line and press F9 to set a break point.

- Now, right click on the ShuttlePB project (not the solution) and select 'Properties'.

- In the left window select 'Debugging', and then in the right make the following changes:
'Command' should be set to: $(OrbiterDir)\Orbiter.exe
'Working Directory' should be set to: $(OrbiterDir)

That tells the debugger to use the Orbiter executable and start in the orbiter directory. Press OK to close the property page.

- Now press F5 to run the addon. It should compile and then start Orbiter. Select the 'Brighton beach' scenario from 'Delta-glider'. Orbiter should start to load and then stop when our break point is hit. This will happen when the ShuttlePB dll is loaded as part of that scenario. You can now hit F10 to step through the code, or F5 to continue execution.

Congratulations, you are debugging an Orbiter add-on.

Now we will create our own simple add-on from scratch.

- Close the ShuttlePB solution if open.

- Select 'File\New\Project'. You will see the New Project screen.

- Under 'Templates' (on the left) select Visual C++. Then in the middle window select 'Empty Project', then OK. You could start with a Win32 DLL, but this way has less clean up.

- Right click on your project and select 'Properties'. Then click 'Configuration Manager' on the top right. We need to remove the x64 configurations. To do this select the combo box under 'Active Solution platform' and the <edit>. Select the x64 configuration and the 'Remove'. Do the same in the combo box under 'Platform'--edit, then remove the x64 configuration. Click Close, and the OK to close the property page. We are not ready to setup the debugger yet because we have not added the property pages. We do that next.

- Click on the 'Property Manager' tab and expand your project node. You should see 'Debug' and 'Release' | Win32 nodes. Right click on the Debug node and select 'Add existing property sheet'. Navigate the open file dialog to 'C:\Orbiter\Orbitersdk\Resources' and select the 'Orbiter vessel.props' file. Then press Open to add it. Since you are in the Debug node, do that again, but this time select the 'Orbiter debug.props' file. You have now added the 'vessel' and 'debug' property sheets to your 'Debug' configuration.

- Now right click on the 'Release' node and do the same thing, adding the 'Orbiter vessel.props' file. You don't need to add the Debug properties to the Release configuration.

- Now we can setup the debugger. We do this the same as we did for ShuttlePB: Right click on the project and select 'Properties'. In the left window select 'Debugging', and then in the right make the following changes:
'Command' should be set to: $(OrbiterDir)\Orbiter.exe
'Working Directory' should be set to: $(OrbiterDir)

- Before we close the properties window we need to do one more thing: In the left screen select 'General', and then on the right for 'Configuration Type' select 'Dynamic Library (.dll)'. Press OK to close.

- We are ready to add our skeleton add-on file. Our add-on won't have a mesh, so it won't be visible, but we will have it write a message to the screen so that we know it is running.

- Select the 'Solution Explorer' tab. Then right click 'Source Files' and select 'Add -> New Item'. In the Add New Item dialog select 'C++ File (.cpp)', give it a name and press 'Add'.

- Open the new file and paste in this code:

Code:
#define STRICT
#define ORBITER_MODULE

#include "orbitersdk.h"

class MyAddon : public VESSEL3 {
public:
	MyAddon(OBJHANDLE hVessel, int flightmodel);
	~MyAddon();
	void clbkSetClassCaps(FILEHANDLE cfg);

private:
};

MyAddon::MyAddon(OBJHANDLE hVessel, int flightmodel)
	: VESSEL3(hVessel, flightmodel)
{
}

MyAddon::~MyAddon()
{
}

void MyAddon::clbkSetClassCaps(FILEHANDLE cfg)
{
	sprintf(oapiDebugString(), "Hello from MyAddon!");
}


// --------------------------------------------------------------
// Vessel initialisation
// --------------------------------------------------------------
DLLCLBK VESSEL *ovcInit(OBJHANDLE hvessel, int flightmodel)
{
	return new MyAddon(hvessel, flightmodel);
}

// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
DLLCLBK void ovcExit(VESSEL *vessel)
{
	if (vessel) delete (MyAddon*)vessel;
}
 
Top