Can't call Haxe function from C++ through a NDLL

I am trying to write a dynamic library in C++ to be used in Haxe applications which contains a function to add call-backs and another function to call all of them with some parameters, but I am unable to get it working. I don’t know if I can’t register the Haxe function to a C++ variable or if I can’t call the Haxe function, though when I try to print the address the function pointer is pointing to it does return a normal address, except that printing the same function’s address in Haxe with cpp.Pointer.addressOf() shows a completely different address. I have also tried using the hxcpp.h headers and lib but it throws linker errors when compiling and I really can’t get it to compile.

This is the C++ side (trimmed + simplified + hx/CFFI.h ver):

typedef value(*Callback)(value);

static Callback fn = nullptr;

static value testndll_call(value name)
{
	std::cout << fn << std::endl;
	return fn(name);
}
DEFINE_PRIM(testndll_call, 1);

static value testndll_add(Callback cbFn)
{
	fn = cbFn;
	return val_null;
}
DEFINE_PRIM(testndll_add, 1);

The Haxe class which does the bridge is super simple:

class TestNDLL
{
	public static function add(func:Dynamic)
		return testndll_add(func);

	public static function call(value:Dynamic):Dynamic
		return testndll_call(value);

	private static var testndll_add = Lib.load("testndll", "testndll_add", 1);
	private static var testndll_call = Lib.load("testndll", "testndll_call", 1);
}

Any help is appreciated! I am willing to give out more detailed information if needed.