since a couples of days I am trying to write a Haxe hxcpp wrapper for linenoise which is programmed in C code; the library is very simple and the header also contains an extern C. I am following the snowkit linc macro template but I can't get a way to compile the C module and that it links with the rest of the project, I am not sure how to continue.
I have no problems to compile the code as a C object and link it with a C executable in my system (OSX el Capitan) so I assume I am doing something wrong in my haxe project, perhaps I can't really link hxcpp with a C library using directly the build process from haxe or I should pipe it manually by writing per hand the commands.
@:keep
@:structAccess
@:include('linenoise.h')
#if !display
@:build(linc.Linc.touch())
@:build(linc.Linc.xml('linenoise'))
#end
extern class LineNoise {
@:native("linenoiseClearScreen")
static function linenoiseClearScreen(): Void;
} //LineNoise
Recently I am getting this error:
g++ -o Test-debug -stdlib=libstdc++ -framework Cocoa -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -m64 @/Users/vresko/projects/linenoise/test/cpp/obj/darwin64-debug/all_objs
Undefined symbols for architecture x86_64:
"_linenoiseClearScreen", referenced from:
Test_obj::main() in ab184b9a_Test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am aware that this error has several mentions, but I am not sure how to solve that within the context of haxe hxcpp.
If I use a C++ wrapper including the hxcpp.h as the typical linc example does the error is still the same, and the function I am declaring here (linenoiseClearScreen) is actually a trivial print statement .
I also read about other possibilities such as CFFI for neko to create a wrapper around the library (I may have read everything on the internet about it) but I wanted to keep the code static linked if possible and compatible with all hxcpp targets.