c++haxehxcpp

How to include libsqlite3 in my Haxe/hxcpp build?


I have a very simple test put together to include SQLite3 in my Haxe build (I know it has SQLite built in, but this issue doesn't just apply here). It looks like so:

@:include("sqlite3.h")
@:buildXml('<files id="haxe" append="true"><compilerflag value="-lsqlite3"/></files>')
extern class SQLite3 {
    @:native("sqlite3_open") public static function sqlite3_open(path: String, outReference:Reference<DBPointer>):Int;
}

@:include("sqlite3.h")
@:native("sqlite3")
extern class DBPointer {

}

This doesn't throw any Haxe errors, but when I try to compile, I get the following error in C++ compilation:

Undefined symbols for architecture x86_64:
"_sqlite3_open", referenced from:
    Main_obj::main() in aea44ed0_Main.o
ld: symbol(s) not found for architecture x86_64

I had figured that adding the buildXml instructions you can see there would be enough to dynamically reference the macOS SQLite library, but it seems that is not the case.

How can I go about including SQLite here?


Solution

  • According to the hxcpp build XML documentation, I believe you should replace

    <compilerflag value="-lsqlite3"/>
    

    with

    <flag value="-lsqlite3"/>
    

    or

    <lib base="sqlite3"/>