#include "XPLMDisplay.h"
#include "XPLMGraphics.h"
#include <string.h>
#if IBM
	#include <windows.h>
#if LIN
	#include <GL/gl.h>
#elif __GNUC__
	#include <OpenGL/gl.h>
	#include <GL/gl.h>

#ifndef XPLM300
	#error This is made to be compiled against the XPLM300 SDK

// An opaque handle to the window we will create
static XPLMWindowID	g_window;

// Callbacks we will register when we create our window
void				draw_hello_world(XPLMWindowID in_window_id, void * in_refcon);
int					dummy_mouse_handler(XPLMWindowID in_window_id, int x, int y, int is_down, void * in_refcon) { return 0; }
XPLMCursorStatus	dummy_cursor_status_handler(XPLMWindowID in_window_id, int x, int y, void * in_refcon) { return xplm_CursorDefault; }
int					dummy_wheel_handler(XPLMWindowID in_window_id, int x, int y, int wheel, int clicks, void * in_refcon) { return 0; }
void				dummy_key_handler(XPLMWindowID in_window_id, char key, XPLMKeyFlags flags, char virtual_key, void * in_refcon, int losing_focus) { }

PLUGIN_API int XPluginStart(
							char *		outName,
							char *		outSig,
							char *		outDesc)
	strcpy(outName, "HelloWorld3Plugin");
	strcpy(outSig, "xpsdk.examples.helloworld3plugin");
	strcpy(outDesc, "A Hello World plug-in for the XPLM300 SDK.");
	XPLMCreateWindow_t params;
	params.structSize = sizeof(params);
	params.visible = 1;
	params.drawWindowFunc = draw_hello_world;
	// Note on "dummy" handlers:
	// Even if we don't want to handle these events, we have to register a "do-nothing" callback for them
	params.handleMouseClickFunc = dummy_mouse_handler;
	params.handleRightClickFunc = dummy_mouse_handler;
	params.handleMouseWheelFunc = dummy_wheel_handler;
	params.handleKeyFunc = dummy_key_handler;
	params.handleCursorFunc = dummy_cursor_status_handler;
	params.refcon = NULL;
	params.layer = xplm_WindowLayerFloatingWindows;
	// Opt-in to styling our window like an X-Plane 11 native window
	// If you're on XPLM300, not XPLM301, swap this enum for the literal value 1.
	params.decorateAsFloatingWindow = xplm_WindowDecorationRoundRectangle;
	// Set the window's initial bounds
	// Note that we're not guaranteed that the main monitor's lower left is at (0, 0)...
	// We'll need to query for the global desktop bounds!
	int left, bottom, right, top;
	XPLMGetScreenBoundsGlobal(&left, &top, &right, &bottom);
	params.left = left + 50;
	params.bottom = bottom + 150;
	params.right = params.left + 200;
	params.top = params.bottom + 200;
	g_window = XPLMCreateWindowEx(&params);
	// Position the window as a "free" floating window, which the user can drag around
	XPLMSetWindowPositioningMode(g_window, xplm_WindowPositionFree, -1);
	// Limit resizing our window: maintain a minimum width/height of 100 boxels and a max width/height of 300 boxels
	XPLMSetWindowResizingLimits(g_window, 200, 200, 300, 300);
	XPLMSetWindowTitle(g_window, "Sample Window");
	return g_window != NULL;

PLUGIN_API void	XPluginStop(void)
	// Since we created the window, we'll be good citizens and clean it up
	g_window = NULL;

PLUGIN_API void XPluginDisable(void) { }
PLUGIN_API int  XPluginEnable(void)  { return 1; }
PLUGIN_API void XPluginReceiveMessage(XPLMPluginID inFrom, int inMsg, void * inParam) { }

void	draw_hello_world(XPLMWindowID in_window_id, void * in_refcon)
	// Mandatory: We *must* set the OpenGL state before drawing
	// (we can't make any assumptions about it)
						 0 /* no fog */,
						 0 /* 0 texture units */,
						 0 /* no lighting */,
						 0 /* no alpha testing */,
						 1 /* do alpha blend */,
						 1 /* do depth testing */,
						 0 /* no depth writing */
	int l, t, r, b;
	XPLMGetWindowGeometry(in_window_id, &l, &t, &r, &b);
	float col_white[] = {1.0, 1.0, 1.0}; // red, green, blue
	XPLMDrawString(col_white, l + 10, t - 20, "Hello world!", NULL, xplmFont_Proportional);

54 comments on “Hello World (SDK 3)

  1. Hi,

    I downloaded this Hello World project for Visual Studio 2010.
    I installed a fresh copy of Visual Studio 2010 with SP1
    The project is compiling without problem, and I copied the file in : “…./Resources/plugins/X-Plane-11-Window-API-Sample/64/win.xpl”.

    I launch XPlane11, the plugin is not loaded and the log.txt file shows:
    “> : Error Code = 127 : The specified procedure could not be found.”

    Can you help ?

    1. I can’t reproduce this. The error indicates that one of the five required callbacks is missing from the plugin. Since the sample code implements all 5, I suspect the error either comes from some another plugin, or it’s caused by a modification you made to the code.

  2. Thank you for the reply.

    I didn’t touch any code in the sample, don’t have any other plugin installed, and the visual studio 2010 is a fresh install.

    I reproduced on another PC with all new fresh installs :
    – Visual Studio 2010 SP1 from MSDN
    – Latest Xplane11 version from Steam
    – An untouched Hello-World-SDK-3 project directly from your ZIP¨

    It compiles without any warning or errors and I deploy the generated (in release mode) win.xpl in the …/Resources/plugins/Hello-World-SDK-3/64/win.xpl
    and same result “Error Code = 127 : The specified procedure could not be found.” In the log.txt, so I assume it can be reproduced on many PCs.

    I suspect a linker or compiler option not set in your sample and that I didn’t notice in the documentation ?

      1. Hi,

        I know this is an old thread, but thought to drop my 2 cents:
        I won’t be surprised if you need to install redistributable visual studio 2010, you can found on in:

        But I will point out that in my opinion, it is better to use VS 2015/2017 since in most Win10/Win7 OSes users probably have one of these files as part of other application installation.
        LR team always use here the lowest common denominator, like X-Code 3.2 project. In todays OSX it is hard to find that old X-Code version. It will probably work well with X-Code-6 or 7 too.

      2. Having the same problem when doing a cross-compile from Linux. Build against XPLM 2.1: works perfectly. Build against XPLM 3.0: Error Code = 127 : The specified procedure could not be found
        I checked using dependency walker 2.2 and all 5 functions are definitely in the exported symbols list. I even checked to make absolutely 100% by manually prefixing __declspec(dllexport). Didn’t help either.

      3. I’ve done a bunch more digging and found that the problem exists in the import library XPLM_64.lib that you ship in the SDK. If I substitute the 3.0 import library into the 2.1 SDK and build against it (without using any 3.0 features), I still get the procedure not found error. This leads me to believe that there’s some subtle breakage in the exported symbol names between the import library and how XPLM_64.lib is assembled, leading to a symbol lookup error on load. Unfortunately, the error message in the log file doesn’t tell me which symbol is missing, only that “some” symbol is missing.
        Currently the only workaround I see is attempting to construct my own import library directly from XPLM_64.dll.

  3. Hi Philipp,
    The reason we used Visual Studio 2010 with your sample is because in the sample download title your mention “For Visual Studio 2010” and we wanted to use the sample the way you told us for a first test (It’s our first XPlane plugin, so we don’t know anything about your practices yet). We had to download Visual Studio 2010 from Microsoft MSDN because we don’t use it anymore for years

    To go on with our project, we downloaded the 64 bit version of the SDK (we had some difficulty to find the files, the links on your website seem dead).
    Now with Visual Studio 2017, our first plugin prototype is working well in Xplane11 linked to the 64 bits version of the 2.1.2 SDK.

    We will go on with this version of the SDK and come back when we are able to use the SDK 3.0 (may be more feedback from other users who reproduce the problem ?)

    In the meantime, thank you for your time.

  4. When attempting to compile in VS2010 I get many errors.

    At first it is this:

    1> Add directive to ‘StdAfx.h’ or rebuild precompiled header
    1>c:\users\sarah\documents\visual studio 2010\projects\hello world\hello world\hello world.cpp(114): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include “StdAfx.h”‘ to your source?

    when I add #include “StdAfx.h” to the top of the .cpp file I get many more errors all coming from the GL/gl.h file. Anyone else had similar issues?

    1. In VS2017 you can solve this problem by disabling precompiled headers: Config Properties -> C/C++ -> Precompiled Headers -> Select “Not Using Precompiled Headers”.

  5. I copied the unzipped folder into the plugins folder and it does not work.
    It says fetching plugins in my log but does not fetch this one. Below is what is shown in my log:

    Fetching plugins for C:\Users/sarah/Desktop/X-Plane 11/Resources/plugins
    Loaded: C:\Users/name/Desktop/X-Plane 11/Resources/plugins/PluginAdmin/64/win.xpl (xpsdk.examples.pluginadmin).
    I found the following scenery packages (prioritized in this order):
    0 Custom Scenery/Global Airports/
    1 Custom Scenery/KLAS Las Vegas Mc Carran/

    1. Just unzipping the folder you download here is not enough—you’ll need to compile it first. See the “General Documentation” section here for some background on how the plugin system works.

      1. Thanks Tyler,

        I know that now. I am still having troubles though getting it to compile on VS 10. I am getting the errors –>

        Error 1 error C1189: #error : This is made to be compiled against the XPLM300 SDK
        2 IntelliSense: #error directive: This is made to be compiled against the XPLM300 SDK
        3 IntelliSense: identifier “XPLMCursorStatus” is undefined
        4 IntelliSense: identifier “xplm_CursorDefault” is undefined
        5 IntelliSense: identifier “XPLMCreateWindow_t” is undefined
        6 IntelliSense: identifier “xplm_WindowLayerFloatingWindows” is undefined
        7 IntelliSense: identifier “xplm_WindowDecorationRoundRectangle” is undefined
        8 IntelliSense: identifier “XPLMGetScreenBoundsGlobal” is undefined
        9 IntelliSense: identifier “XPLMCreateWindowEx” is undefined
        10 IntelliSense: identifier “XPLMSetWindowPositioningMode” is undefined
        11 IntelliSense: identifier “xplm_WindowPositionFree” is undefined
        12 IntelliSense: identifier “XPLMSetWindowResizingLimits” is undefined
        13 IntelliSense: identifier “XPLMSetWindowTitle” is undefined
        14 IntelliSense: identifier “xplmFont_Proportional” is undefined

  6. Hi all, i just downloaded this plugin ad am not sure where to go from here. I am new to the whole idea of an SDK so if anyone is able to point me in the right direction, please let me know.

    1. I tried referencing the documentation but did not understand exactly where to go from there, if anyone was wondering.

  7. Hi,
    I get the following error when i try to build the hello world project in code blocks 17.12
    I don’t think it’s a bug in the sdk. I tried to make a directory OpenGL containing the gl.h file and added this in the search directory in the global compiler settings, but that didn’t help.

    ||=== Build: Release in test (compiler: GNU GCC Compiler 64 bit) ===|
    C:\codeblocks\projects\test\main.cpp|13|fatal error: OpenGL/gl.h: No such file or directory|
    ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

    Can you help ?

  8. Hi,
    I get the following error when i try to build the ‘hello world’ project with codeblocks 17.12
    I don’t think i it’s a sdk bug. I tried to make a OpenGl directory containing the gl.h file and added the path to the search directory of the global compiler settings, but that didn’t help.

    ||=== Build: Release in test (compiler: GNU GCC Compiler 64 bit) ===|
    C:\codeblocks\projects\test\main.cpp|13|fatal error: OpenGL/gl.h: No such file or directory|
    ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

    Can you help me please ?

  9. Hi,
    i am getting the following error when i try to build the ‘hello world’ project with codeblocks 17.12.
    I don’t think it’s een sdk bug. I have tried to make a directory OpenGL containing the file gl.h and
    added the path to the search directory of the global compiler settings, but that didn’t help.

    ||=== Build: Release in test (compiler: GNU GCC Compiler 64 bit) ===|
    C:\codeblocks\projects\test\main.cpp|13|fatal error: OpenGL/gl.h: No such file or directory|
    ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

    Can you help me ?

  10. Hi, is there a way to export for all three platforms from Xcode, or if I want to have my plugin available for windows Mac and Linus I have to compile on each machine?

  11. Hello, how can I display Chinese in the x-plane plug-in?For example, I use “Hello World” instead of “你好世界”.
    I have been confused by this problem for many days, I have looked up a lot of materials but still haven’t found it. For this reason, I hope to get official help, I will be grateful!

    1. I’m not sure I understand the issue… I confirm that the proportional font at least supports drawing Chinese literal characters like this:

      XPLMDrawString(col_white, x_left, y_bottom, "你好世界", NULL, xplmFont_Proportional);

          1. The built-in XPLM APIs for font drawing don’t support changing the typeface characteristics—you can choose one of the XPLMFontID enums only. You’ll need to use custom OpenGL drawing to do custom fonts.

  12. Download file and included header files based upon 3.0.0. Opened project file with Visual Studio 2017 and get numerous errors like:

    Error (active) E1696 cannot open source file “XPLMDisplay.h”

    Any idea?

    1. It sounds like you might not have unzipped everything from the download? After unzipping, you should have:

      • Hello-World-SDK-3.vcxproj
      • Hello-World-SDK-3.cpp
      • SDK\ (with a bunch of subdirectories)
  13. The build fails out of the box on Xcode 10.1 with the following error:

    “/clang:-1: linker command failed with exit code 1 (use -v to see invocation)”

    The build log shows the actual error is:

    clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
    ld: library not found for -lstdc++

    Although this is shown as a warning, it causes the link and build to fail. Simple solution is to change the deployment target to 10.9 as the warning suggests.

    1. Thanks for bringing this to our attention. I’ve just pushed an update to the code samples that uses Xcode 6 as its new minimum and requires macOS 10.9 and libc++.

    1. At present, we don’t provide callbacks for event notifications like close, pop out, etc. Your best bet for now is to poll (probably in your draw method) the window’s state.

  14. Compiling the project doesn´t work. I am using Microsoft Visual Studio 2017 with the Windows 8.1 SDK (I tried also the Windows 10.0.17763.0 SDK). I got some error messages:

    C2039 “handleRightClickFunc”: Ist kein Element von “XPLMCreateWindow_t”

    I looked in the definition of the function XPLMCreateWindow_t in XPLMDisplay.h. There is really no element which calls “handleRightClickFunc”:

    typedef struct {
    int structSize;
    int left;
    int top;
    int right;
    int bottom;
    int visible;
    XPLMDrawWindow_f drawWindowFunc;
    XPLMHandleMouseClick_f handleMouseClickFunc;
    XPLMHandleKey_f handleKeyFunc;
    XPLMHandleCursor_f handleCursorFunc;
    XPLMHandleMouseWheel_f handleMouseWheelFunc;
    void * refcon;
    } XPLMCreateWindow_t;

    C2065 “xplm_WindowLayerFloatingWindows”: nichtdeklarierter Bezeichner

    “xplm_WindowLayerFloatingWindows” is really not declared.

    Does someone have any advice for me?

    1. It sounds like you either have an old version of the plugin SDK, or you haven’t defined the correct symbols for your build (you want all of XPLM200, XPLM210, XPLM300, and XPLM301). This is a little puzzling, because the project as you download it here should “just work” (I confirm this is the case here).

      I’d suggest redownloading it to get a fresh .vcxproj and SDK directory.

  15. I can’t get this to work. I downloaded the project from this site as well as the 3.0 SDK. Also installed Visual Studio 2019 Community.

    It builds fine, but when I try to load it in XPlane it doesn’t show up. The log file shows this error:

    C:\Program Files (x86)/X-Plane 11/Resources/plugins/Hello-World-SDK-3/64/win.xpl : Error Code = 127 : The specified procedure could not be found.

      1. What I would like is a transparent background that can be moved in 2d like it can in VR.

        In Xchecklist I use params.decorateAsFloatingWindow = xplm_WindowDecorationSelfDecorated; in VR which can be moved.

        It would be nice if it was possible to do the same in 2d.

  16. Hi,

    May be older than any SDK but the “Description” field for the Datarefs [sim/graphics/view/] view_pitch , view_roll and view_heading is ambiguous for the first two and erroneous for the third one. A proposed fix would be to copy paste the ones of [sim/flightmodel/position/] theta, phi and psi (NOT their _true versions) and simply replace both occurrences of “aircraft” by “camera”.

    Best wishes,

  17. Hello,
    XPLMDrawString: input character string is not const. Seems likely an oversight… (Wasn’t sure if this would qualify for the bug reporter.)

  18. Hello,
    I am compiling the plugin in VS 2019, and I have all the options as described here and on //developer.x-plane.com/article/building-and-installing-plugins/#Compiling_Plugins
    The plugin does compile without errors and the .xpl file does get generated. However, when I launch X-Plane I get this:
    C:\X-Plane 11/Resources/plugins/Hello-World-SDK-3/64/win.xpl : Error Code = 193 : %1 no es una aplicación Win32 válida.
    (Not a valid Win32 application)

    Any hint?

  19. Hi, I’m trying to compile this on Linux with gcc version 9.3.0 and I get:

    Hello-World-SDK-3.cpp: In function ‘void draw_hello_world(XPLMWindowID, void*)’:
    Hello-World-SDK-3.cpp:108:44: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
    108 | XPLMDrawString(col_white, l + 10, t – 20, “Hello world!”, NULL, xplmFont_Proportional);
    | ^~~~~~~~~~~~~~

  20. Good day! I understand correctly, after I compiled the dll, its extension needs to be changed to “xpl”?

  21. I have been using xplane since version 9, but have only now tried to use plugins.
    I am using xplane 11.5, Hello-World-SDK-3, and visual studio 2019. Hello-world-sdk-3.cpp and .vcxproj are there as well as the directory SDK with all subdirectories. Each of these directories are specified in the path variable, as well as in visual studio. When I try to build, I get six C1083 “cannot open include file” errors. I have verified these include files are in the Hello-World-SDK-3/SDK directories, with the following syntax:
    #include “XXXxxxxx.h”. I tried changing the syntax to #include but the include files were still not found.
    Any suggestions would be appreciated. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please do not report bugs in the blog comments.
Only bugs reported via the X-Plane Bug Reporter are tracked.