Is there a way to expose a Haxe library as a library for another target


I wanted to know whether or not there is a way for me to write a library in Haxe and compile it to a library built for another platform. For example, if I wrote a library that was a Haxe implementation of some algorithm, could I compile that to a Java .jar, a Python library, a Javascript module, and .so/.dll shared libraries? It seems like that could be very useful, especially for people who want to develop SDK’s or libraries for interacting with a tool or platform for a collection of languages.

Yes, you can do this.
Check this for a start point: Compiling libraries without main class - Compilation - Haxe programming language cookbook

Also, here is additional information:

HXCPP can create C++ libs as well with -D static_link and -D dll_export

Hope it helps! :slight_smile:


It’s definitely possible.
A few years ago I’ve created a library which simulated a battle system of a Clash-Of-Clans-like game, which was compiled as a shared library for a c++ clients on ios and android (with an attempt to integrate it as a js library + js vm), as a php library on server and as swf library for an as3 client.
Js, php and swf were pretty easy to implement. The most troubles were caused while implementing a shared c++ lib for different OSes and architectures.

1 Like

Wow! Cool! It’s great that Haxe can do that. This could be very useful. :+1: