This project is meant to showcase how to use the zig toolchain to cross-compile a plugin for X-Plane 12 on Linux/Ubuntu.
The script compiles plugins for
- Windows x86
- Linux x86
- Mac Universal - x86 + ARM
This showcase is based on the Menu SDK Sample from the X-Plane developer documentation. To support cross-compiling for Macs based on the M1/M2 processors (ARM64), the project is using the X-Plane beta SDK supporting the new 4.0 API and ARM64 Macs.
https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager
sudo snap install zig --classic --beta
sudo apt install make
https://github.com/tpoechtrager/cctools-port
This project is being used to create the Universal (fat) binary for Mac Intel/ARM64. In order to compile the project, we need a clang/clang++
compiler. Zig is LLVM based and provides this capability. For the cctools-port
to compile/install we need the configure script to find the clang/clang++
compiler. We are doing this by creating 2 scripts
cat <<EOF > /usr/bin/clang
#!/bin/bash
zig cc "\$@"
EOF
cat <<EOF > /usr/bin/clang++
#!/bin/bash
zig c++ "\$@"
EOF
sudo chmod 755 /usr/bin/clang
sudo chmod 755 /usr/bin/clang++
git clone https://github.com/tpoechtrager/cctools-port.git
cd cctools-port/cctools
./configure
make
sudo make install
make
You will find the resulting plugin in build/X-Plane-Menu-SDK-Sample. To install it, move the directory to your X-Plane installation into the X-Plane 12/Resources/plugins
directory.