The C++ target uses various C++ compilers, which are assumed to be already installed on the system, to create native executables or libraries. The compilation happens in two phases. Firstly, the Haxe compiler generates source, header and build files in an output directory. Secondly, the
hxcpp Haxelib library is invoked to run the system compilers and linkers required to generate the ultimate result.
Before you can use the C++ target, you need to install:
hxcpp- install with
haxelib install hxcpp.
clang++, or MSVC++.
System compilers are supported on the three primary operating systems - Mac, Linux, and Windows.
On Mac, it is recommended that you install the latest Xcode from the Mac App Store.
On Linux, it is recommended that you use the system package manager to install the compilers.
On Windows, Microsoft Visual Studio is recommended. On Windows, you can also use
gcc-based compilers. A minimal distribution is included in a Haxelib library, and can be installed with
haxelib install minimingw.
hxcpp can be used to compile for non-host architectures if you have a suitable cross-compiler installed. The compilers are usually supplied in the form of a Software Development Kits (SDK), or in the case of iOS devices, come with the system compiler (Xcode). Selecting which compiler to use is achieved by defining particular variables in the
hxcpp build environment. Note that the
hxcpp build tool is only responsible for producing a native executable or a native library (static or dynamic), not the complete bundling and packaging of assets and meta-data that is typically required for mobile devices. Additional Haxe libraries can be used for this task.