How can I add compiler flags via project.xml or where is hxcpp_config.xml? I need to include cpp files and I don’t want to use absolute path, because I don’t want to edit the whole cpp Library.
Thank you. One more question … I read the whole Internet and I found some answers from you too related to this topic
I was able to include cpp files and I tested some functions/classes of the library (bullet-physics), and they work. E.g. when I trace an instanced Class from the library I get back a Pointer. That means it’s there and the library is included (I think).
But when I call a function or class that in turn call this function btAlignedAllocInternal(unsigned int,int) the compiler complains about LNK2019 Error. I don’t unterstand that. Maybe a 32-Bit/64-Bit issue? Unfortunately I can’t test it out, because when I compile for 64 bit I get a Null Function Pointer Exception.
I have not really an idea of coding cpp, I would like to know what could be wrong. But perhaps it’s because of the library itself.
I already have a @:buildXml with compilerflag value with the path to the source files. But I don’t really understand where the lib is? It compiles and generates the lib and then wants to link this lib? But where is the lib then, so I can include it?
And that works, because the source files are found. But I don’t know where the lib is then.
// files id=’_ lib _’ compilerflag value=’- ???
I’m sorry, I am a cpp noob.
Or is it then in Application-Main.lib and I just have to include that? That would be really amazing.
(tags not allowed)
EDIT:
I really don’t know how to link the library. From my understanding I thought it would be compiled with the other openfl and my haxe source an is in ApplicationMain.lib. I can’t find other libs in my project.
Another trick you can use is put the bullet-time library into a haxelib, and then you can use the “${haxelib:myhaxelibname}” in any of the xml injection code to allow the path to be changed on different machines.
I thought the libs where built by compiling the haxe bindings because they include the cpp-sources as well, but I had to compile the libs with VS first and include them then. Searched the whole internet in the absolute wrong places haha. Name Mangling, 32-64 bit issue … NO I HAD TO INCLUDE THE LIBRARYs, I could bite me in my ass.
extern class BtVector3 {
@:native(“new btVector3”)
public static function create(x:BtScalar = 0, y:BtScalar = 0, z:BtScalar = 0):cpp.Pointer;
public function setX(x:BtScalar):Void;
}
When I want to call btvector.setX() it gives an error.
cpp.Pointer haxebullet.BtVector3 has no field setX
EDIT:
Hm. I saw your Video WWX 2014, Hugh. And updated hxcpp to newest dev build + haxe nightly build. I really don’t know why it does not run. I use FlashDevelop and fdbuild.exe runs "haxlib run lime build “project.xml” -debug -Dfdb.
You might be missing the @:structAccess meta to work nicely with cpp.Pointer and extern.
However, skip forward a year to wwx2015 and you will see that the “cpp::Reference” is a nicer way of dealing with pointers.
See:
Where you would use “BtVector3Ref” in your code everywhere instead of cpp.Pointer<BtVector3>, and the “.” syntax should work.
It may also be possible to use “BtVectrorStruct” if the native class does not have a constructor/destructor that needs to be called. Then you do no need new/delete.
But this is some code from the Haxe Bindings, and it should work, but It doesn’t.
// ------------------------------------------------------
#if js
@:native('Ammo.btVector3')
#elseif cpp
@:include("LinearMath/btVector3.h")
@:native("::btVector3")
@:structAccess
@:unreflective
#end
extern class BtVector3 {
#if js
public function new(x:BtScalar = 0, y:BtScalar = 0, z:BtScalar = 0):Void;
#elseif cpp
@:native("new btVector3")
public static function create(x:BtScalar = 0, y:BtScalar = 0, z:BtScalar = 0):cpp.Pointer;
#end
public function setX(x:BtScalar):Void;
public function setY(y:BtScalar):Void;
public function setZ(z:BtScalar):Void;
public function setW(w:BtScalar):Void;
public function x():BtScalar;
public function y():BtScalar;
public function z():BtScalar;
public function w():BtScalar;
public function length():BtScalar;
public function normalize():BtVector3;
}
The compiler knows not about the functions. By the way: how do i format Syntax Code here?