{"id":8254,"date":"2018-02-21T11:49:12","date_gmt":"2018-02-21T11:49:12","guid":{"rendered":"http:\/\/localhost:8105\/?p=8254"},"modified":"2021-12-07T15:57:43","modified_gmt":"2021-12-07T15:57:43","slug":"compiling-the-extplane-plugin-on-linux-and-windows","status":"publish","type":"post","link":"https:\/\/blog.shahada.abubakar.net\/?p=8254","title":{"rendered":"Compiling The ExtPlane Plugin (on Linux and Windows)"},"content":{"rendered":"<div>There appears to be quite a bit of updates going on with the ExtPlane plugin source code in the last few months, and it turned out some of these are needed to fix some of the bugs I am facing when using it. Unfortunately, to get the latest and greatest version, you have to compile it yourself. Here are my notes on how to go about compiling the plugin on Linux and Windows.<\/div>\n<div><\/div>\n<div><strong>Note: <i>If you are using my Pi-XPlane-FMC-CDU, you can just use the pre-compiled binaries linked to in my post <a href=\"https:\/\/blog.shahada.abubakar.net\/?p=8379\">here<\/a>.<\/i> This post is more for those who would like to know more about the compilation process, and\/or want to compile it themselves.<\/strong><\/div>\n<div><\/div>\n<div><span style=\"font-size: 18px;\"><b>Compiling for Linux<\/b><\/span><\/div>\n<div><\/div>\n<div>I was able to compile it for Linux quite easily, on my Ubuntu 16.04 desktop PC. Starting with a fresh Ubuntu install:<\/div>\n<div><\/div>\n<ul>\n<li>Update OS\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">sudo apt-get update<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">sudo apt-get upgrade<\/span><\/li>\n<\/ul>\n<\/li>\n<li>Install dependencies\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">sudo apt-get install git<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">sudo apt-get install qt5-qmake qt5-default qtbase5-dev<\/span><\/li>\n<\/ul>\n<\/li>\n<li>Install ExtPlane SDK\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">cd<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">mkdir src<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">cd src<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">wget <a href=\"http:\/\/developer.x-plane.com\/wp-content\/plugins\/code-sample-generation\/sample_templates\/XPSDK300.zip\">http:\/\/developer.x-plane.com\/wp-content\/plugins\/code-sample-generation\/sample_templates\/XPSDK300.zip<\/a><\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">unzip XPSDK300.zip<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">mv SDK XPlaneSDK<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">rm XPSDK300.zip<\/span><\/li>\n<\/ul>\n<\/li>\n<li>Clone the ExtPlane Source Code\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">git clone\u00c2\u00a0<a href=\"https:\/\/github.com\/vranki\/ExtPlane.git\">https:\/\/github.com\/vranki\/ExtPlane.git<\/a><\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">cd ExtPlane<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">qmake<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">make<\/span><\/li>\n<\/ul>\n<\/li>\n<li>And that&#8217;s it &#8230; the linux-version of the plugin can be found in\u00c2\u00a0<span style=\"font-family: 'courier new', courier, monospace;\">extplane-plugin\/extplane\/64\/win.xpl<\/span>.<\/li>\n<\/ul>\n<div><\/div>\n<div><\/div>\n<div><span style=\"font-size: 18px;\"><b>Compiling for Windows<\/b><\/span><\/div>\n<div><b>\u00a0<\/b><\/div>\n<div>The last time I actually compiled anything for windows, the compiler had the name &#8220;Borland&#8221; in it<\/p>\n<div data-pm-slice=\"1 1 []\" data-en-clipboard=\"true\"><b>\ud83d\ude03<\/b><span style=\"color: initial;\"><span style=\"color: initial;\">. But since my proper X-Plane Flight Sim setup runs on a dedicated WIndows PC, I need a WIndows ExtPlane plugin also. After a few false starts (Visual Studio Community Edition &#8230;<b style=\"color: initial;\">\ud83d\ude03<\/b><\/span><\/span><span style=\"color: initial;\">), here are my notes on setting up a Linux-ish Windows build environment as well as compiling the ExtPlane plugin.<\/span><\/div>\n<\/div>\n<div><\/div>\n<div>These notes are for a Fresh Windows 7 (fully updated) with just a Chrome browser installed.<\/div>\n<div><\/div>\n<ul>\n<li>Install MSYS2. MSYS2 is an environment for building and packaging lots of open-source software. It provides a GNU toolchain that lets you build native windows apps, and also provides a UNIX-ish environment to build them in.\n<ul>\n<li>browse to <a href=\"http:\/\/www.msys2.org\">http:\/\/www.msys2.org<\/a><\/li>\n<li>Click on the &#8220;<span style=\"font-family: 'courier new', courier, monospace;\">msys2-x86_64-20161025.exe<\/span>&#8221; button at the top (x86_64 indicates a 64-bit version) and run the downloaded installer.<\/li>\n<li>Press Next, and install into &#8220;<span style=\"font-family: 'courier new', courier, monospace;\">C:msys64<\/span>&#8220;.<\/li>\n<li>Press Next. Press Finish when done.<\/li>\n<li>Using Windows Explorer, open C:MSYS64 and right-drag the &#8220;<span style=\"font-family: 'courier new', courier, monospace;\">msys2.exe<\/span>&#8221; and &#8220;<span style=\"font-family: 'courier new', courier, monospace;\">mingw64.exe<\/span>&#8221; to your desktop, and create shortcuts. Both of these can be used to open a shell prompt. They differ in the paths and environment they have set up, in particular &#8220;mingw64&#8221; has \/mingw64\/bin on its path, which is where the 64-bit compiler resides. Use &#8220;mingw64&#8221; when building stuff.<\/li>\n<\/ul>\n<\/li>\n<li>Update your msys2 packages:\n<ul>\n<li>In a MSYS2 terminal:\n<ul>\n<li>update package db and core packages:\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">pacman -Syu<\/span><\/li>\n<li>I was prompted to remove &#8220;<span style=\"font-family: 'courier new', courier, monospace;\">catgets<\/span>&#8221; and &#8220;<span style=\"font-family: 'courier new', courier, monospace;\">libcatgets<\/span>&#8220;, and just agreed to it.<\/li>\n<li>I was also prompted to close the window at the end of the update.<\/li>\n<\/ul>\n<\/li>\n<li>update other packages\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">pacman -Suu<\/span><\/li>\n<\/ul>\n<\/li>\n<li>Install vim\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">pacman -S vim<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">ln -s \/usr\/bin\/vim \/usr\/bin\/vi<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Configure OpenSSH Service. This lets you ssh into a windows box into a msys2\/mingw64 terminal. Pretend your Windows box is Linux !\n<ul>\n<li>Right-click on the msys2 shell icon, and &#8220;Run as Administrator&#8221;\n<ul>\n<li>Install the following packages:\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights<\/span><\/li>\n<\/ul>\n<\/li>\n<li>Execute this script to set things up automatically\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">wget\u00c2\u00a0<a href=\"https:\/\/gist.github.com\/samhocevar\/00eec26d9e9988d080ac\/raw\/3dfeffef2bec8134d38cad8ff92f931b228ee7ba\/gistfile1.sh\">https:\/\/gist.github.com\/samhocevar\/00eec26d9e9988d080ac\/raw\/3dfeffef2bec8134d38cad8ff92f931b228ee7ba\/gistfile1.sh<\/a>\u00c2\u00a0-O z.sh<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">sh z.sh<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">rm z.sh<\/span><\/li>\n<\/ul>\n<\/li>\n<li>Open Port 22 to allow ssh connections to your Windows PC\n<ul>\n<li>Start -&gt; Run -&gt; &#8220;Windows Firewall with Advanced Security&#8221;<\/li>\n<li>Select &#8220;Inbound Rules&#8221;, the right-click &#8220;Inbound Rules&#8221; and choose &#8220;New Rule&#8221;.<\/li>\n<li>Select Port, Next<\/li>\n<li>Select TCP, and specify local port &#8220;22&#8221;, Next<\/li>\n<li>Select &#8220;Allow the Connection&#8221;, Next<\/li>\n<li>Tick everything, Next<\/li>\n<li>Name this rule &#8220;Open Port 22 for ssh&#8221; and press Finish<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8908\" rel=\"attachment wp-att-8908\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8908\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-1.png\" alt=\"\" width=\"1920\" height=\"1080\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-1.png 1920w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-1-300x169.png 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-1-1024x576.png 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-1-768x432.png 768w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-1-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/div>\n<ul>\n<li style=\"display: inline; list-style: none;\">\n<ul>\n<li style=\"display: inline; list-style: none;\">\n<ul>\n<li>The default shell you get when you ssh in is msys2. To change it to mingw64:\n<ul>\n<li>edit \/etc\/ssh\/sshd_config:\n<ul>\n<li>find the line set PermitUserEnvironment, remove the &#8220;#&#8221; and change &#8220;no&#8221; to &#8220;yes&#8221;<\/li>\n<\/ul>\n<\/li>\n<li>Set the environment variable MSYSTEM:\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">mkdir ~\/.ssh<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">echo &#8220;MSYSTEM=MINGW64&#8221; &gt; ~\/.ssh\/environment<\/span><\/li>\n<\/ul>\n<\/li>\n<li>restart the service:\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">net stop sshd<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">net start sshd<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>You can now ssh into your windows machine !\u00c2<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Install toolchain and development tools\n<ul>\n<li>In a msys shell:\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\"><span style=\"font-size: 14px;\">pacman -S &#8211;needed base-devel mingw-w64-x86_64-toolchain<\/span><\/span><\/li>\n<li>I pressed ENTER at all the prompts<\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">pacman -S git<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">pacman -S unzip<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Install qt5\n<ul>\n<li>in a msys shell:\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">pacman -S\u00c2\u00a0mingw-w64-x86_64-qt5<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div><\/div>\n<div>Now we are ready to build the Windows version of the ExtPlane plugin. The instructions below download the XPlaneSDK and ExtPlane git repository (what I actually did was to\u00c2\u00a0share the &#8220;src&#8221; folder from my Ubuntu machine (using Samba) and mounted it as &#8220;s:&#8221; on the Windows machine).<\/div>\n<div><\/div>\n<ul>\n<li>in a <u>mingw64<\/u> shell:\n<ul>\n<li>Download X-Plane SDK\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">cd<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">mkdir src<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">cd src<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">wget http:\/\/developer.x-plane.com\/wp-content\/plugins\/code-sample-generation\/sample_templates\/XPSDK300.zip<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">unzip XPSDK300.zip<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">mv SDK XPlaneSDK<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">rm XPSDK300.zip<\/span><\/li>\n<\/ul>\n<\/li>\n<li>Clone the ExtPlane Source Code\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">git clone https:\/\/github.com\/vranki\/ExtPlane.git<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">cd ExtPlane<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">qmake<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">make<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div><\/div>\n<div>We now have the windows version of the plugin in the <span style=\"font-family: 'courier new', courier, monospace;\">extplane-plugin\/extplane\/64\/win.xpl, <\/span>which is actually just a renamed .DLL file. However, this .DLL has dependencies on other .DLLs, and won&#8217;t be able to run under x-plane if those other .DLLs are not present. To see those dependencies, install the <a href=\"http:\/\/dependencywalker.com\/\">Dependency Walker<\/a> utility, and open the win.xpl file with it (Actually you are supposed to be able to use the &#8220;<span style=\"font-family: 'courier new', courier, monospace;\">ldd<\/span>&#8221; command for this, but it didn&#8217;t work on this .dll for me). It will list the dependent .dll files:<\/div>\n<div><\/div>\n<div><a href=\"https:\/\/blog.shahada.abubakar.net\/?attachment_id=8909\" rel=\"attachment wp-att-8909\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8909\" src=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-2.png\" alt=\"\" width=\"1920\" height=\"1080\" srcset=\"https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-2.png 1920w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-2-300x169.png 300w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-2-1024x576.png 1024w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-2-768x432.png 768w, https:\/\/blog.shahada.abubakar.net\/wp-content\/uploads\/2018\/02\/z-2-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/div>\n<div><\/div>\n<div>The fun doesn&#8217;t end there. Those dependent DLLs you copied in, also have their own dependent DLLs, so you will need to go through each one and find their dependencies, and then go through each of those, and so on. One thing that may help is to add the <span style=\"font-family: 'courier new', courier, monospace;\">extplane-plugin\/extplane\/64\/<\/span> folder into the Dependency Walker&#8217;s path, so only those that are really missing will turn up in yellow. It can be frustrating, but almost everything you need will be somewhere in the \/mingw64\/bin folder.<\/div>\n<div><\/div>\n<div>For this build of ExtPlane, here are the dependent .DLLs I found:<\/div>\n<div><\/div>\n<ul>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">XPLM_64.DLL<\/span> is the stub used by the X-Plane SDK to compile this. When actually run, it will be provided by the Flight Sim itself, so we don&#8217;t need to worry about it.<\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">LIBGCC_S_SEH-1.DLL<\/span> (the C runtime),<\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">LIBSTDC++-6.DLL<\/span> (the C++ runtime),\u00c2<\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">QT5CORED.DLL<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">QT5NETWORKD.DLL<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">LIBICUIN58.DLL<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">LIBICUUC58.DLL<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">LIBPCRE2-16-0.DLL<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">LIBWINPTHREAD-1.DLL<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">QT5CORED.DLL<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">QT5NETWORKD.DLL<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">ZLIB1.DLL<\/span><\/li>\n<li><span style=\"font-family: 'courier new', courier, monospace;\">LIBUCIDT58.DLL<\/span><\/li>\n<\/ul>\n<div><\/div>\n<div>Copy them to the same folder where the plugin is located\u00a0 (<span style=\"font-family: 'courier new', courier, monospace;\">~\/src\/ExtPlane\/extplane-plugin\/extplane\/64\/)<\/span>. I&#8217;m not sure if all of them are strictly needed or not.<\/div>\n<div><\/div>\n<div><b><span style=\"font-size: 18px;\">Compiling for Mac OS X<\/span><\/b><\/div>\n<div><\/div>\n<div>Send me a Mac and I will write this part up! \ud83d\ude0d<\/div>\n<div><\/div>\n<div><\/div>\n<div><b><span style=\"font-size: 18px;\">Putting it all Together<\/span><\/b><\/div>\n<div><\/div>\n<div>Copy the src\/ExtPlane\/extplane-plugin\/extplane into your X-Plane Flight simulator&#8217;s Resources\/Plugins directory. I like to rename it with the commit details and the date so it is easy to tell subsequent versions apart.<\/div>\n<div><\/div>\n<div><span style=\"font-size: 18px;\"><b>Notes<\/b><\/span><\/div>\n<div><\/div>\n<ul>\n<li>Since the ubuntu and windows machine are scriptable, it should be possible to write a script that will automatically pull the latest copy, build all the versions for each platform and zip it up properly.<\/li>\n<li>I&#8217;m not sure if the linux version has any dependencies. If someone has a clean linux machine with just X-Plane it would be good to test this out. Let me know the results.<\/li>\n<li>This is my first attempting this, so I would appreciate any feedback you may have in the comments below.<\/li>\n<\/ul>\n<div><\/div>\n<p><i>Originally created with EverNote at 20180221T114912Z<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There appears to be quite a bit of updates going on with the ExtPlane plugin source code in the last few months, and it turned out some of these are needed to fix some&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":8908,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[211],"tags":[],"class_list":["post-8254","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-737-fmc"],"_links":{"self":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/8254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8254"}],"version-history":[{"count":4,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/8254\/revisions"}],"predecessor-version":[{"id":8985,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/8254\/revisions\/8985"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/media\/8908"}],"wp:attachment":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}