Hi,
So you have native code (sum,random), that you want to call from haxe c++ code?
What you have written is almost correct, but like this:
@:include("../../ExternAPI.h")
extern class ExternalAPI {
@:native("::sum")
public static function sum(a:Int, b:Int) : Int;
}
Note the "@:native" to give the actual name of the function, otherwise it assumes it will be an an ExternalAPI_obj namespace. And assuming the sum proto-type is in "ExternAPI.h" (or whatever you want to call it)
You will also probably want to make the include path simpler, but add a "-I" include to the build system, and add a ".lib" to it too. This is done with the build.xml injection:
@:include("ExternAPI.h")
extern class ExternalAPI {
@:native("::sum")
public static function sum(a:Int, b:Int) : Int;
}
@:buildXml("
<files id='haxe'>,
<compilerflag value='-I..'/>
</files>
<target id='haxe'>,
<lib name='../mylib.a'/>
</target>
")
class Test
{
public static function main()
{
trace(ExternalAPI.sum(10,15));
}
}
You can use variables in the Build.xml section. like
<compilerflag value='-I${haxelib:myhaxelib}/include'/>
I talked about this at wwx, see:
http://gamehaxe.com/wwx/wwx2014.swf
Hugh