Building X-Plane Plugins on Windows
This document describes the steps necessary to build plugins on windows.
If we have MS Visual Studio V6, we can start with the sample
projects in the SDK.
Dealing With Old Compilers
If we have a compiler prior to VC6 then we cannot use the SDK project
files but we can still create the project as mentioned below.
If we have a non MS compiler then contact the SDK team and we will see
what we can do.
Compiling C/C++ Plugins
To compile plugin source code on the PC we must do two things: set up the
IBM/APL macros and set up the include paths.
Setting up the APL/IBM macros
The macros APL and IBM are used to differentiate what platform a plugin is
being compiled for. They must be defined before any XPLM_____.h
header is included. There are two ways to define these macros: we
can simply define them in each .c file before including any headers, or we
can use a prefix file, or we can use a command-line option if the compiler
To define the macros in each .c file, make sure each plugin file starts
something like this:
This technique is simple, the only problem is that if we want
to compile this plugin for APL, we have to edit the header and change each
definition of APL and IBM. What a pain!
/* First define the platform */
#define APL 0
#define IBM 1
/* Now include the plugin headers
/* My plugin code then continues */
PLUGIN_API int XPluginStart(...
In the MS compiler project settiings add this to the end of the
preprocessor definitions in the C/C++ General tab.
Setting Up the Include Paths
We must tell the compiler where to find the XPLM headers. In the MS
VC6 compiler project settiings add this to Additional include
directories in the C/C++ Preprocessor tab.
This assumes the SDK has been unzipped on the hard drive
and the directory stucture has not been changed.
To link the code into a plugin, we'll have to add some files to the project and
set up the proper project settings.
Additional Files to Add to the Project
We must add the following files to the project:
In addition, if we are using OpenGL code in the plugin we will need
to link against the OpenGL libraries. Include the following
We will need to create a seperate file that contains the DllMain function
(We can just copy one from the SDK e.g. "CommandSimWin.cpp" and rename it).
XPLM.LIB. This library can be found in the
\SDK\Libraries\Win\ImportLibs subfolder of the XPlane Plugins SDK.
Make sure to use the Win version.
Other Project Settings
This next section lists project settings. I have listed them generically
so we can hopefully spot the version of these settings for the
Executable Name. Make sure the shared library ends with .xpl.
Linker/Project Type. Create a Win32 Dynamic-Link Library.
Linker Entry Points. Use the defaults
Symbol exporting. Use the PLUGIN_API macro and this will be done for