I'm learning haxe with the intent of writing code to be used in cpp, java, and cs products. I've found plenty of documentation for writing haxe source code, but not so much for calling the resulting code from the target platform.
To illustrate, say my haxe code creates a Gizmo object:
class Gizmo {
var data: String;
public function new() {}
public function load(s: String) {
this.data = s;
}
}
Compile using
haxe -D static_link --cpp cpp Gizmo.hx
Which completes successfully. Now I'd like to instantiate a Gizmo in my c++ project. Here's where I'm not finding much guidance available. I'm trying this:
(file: gizmo.cxx)
#include <Gizmo.h>
#include <string>
using namespace std;
int main(int argc, char** args) {
Gizmo *g = new Gizmo();
string s = "xyz";
g->load(s);
return 0;
}
Compile using
g++ -I ~/.haxe/lib/hxcpp/4,2,1/include -I cpp/include -loutput -Lcpp gizmo.cxx
I get a few warnings about 'offsetof' within non-standard-layout type hx::ArrayBase, followed by
gizmo.cxx: In function ‘int main(int, char**)’:
gizmo.cxx:9:6: error: ‘Gizmo’ {aka ‘class hx::ObjectPtr<Gizmo_obj>’} has no member named ‘load’
9 | g->load(s);
| ^~~~
make: *** [Makefile:3: gizmo] Error 1
Any ideas on the issue here, and where can I get examples for calling haxe code from c++? Running into similar problems calling from java and .NET (although with some success).