Hello - I'm trying to use Futhark to create bindings for various things. I'm 
starting with CozoDB as I'm interested in it and the API is tiny. 
<https://github.com/cozodb/cozo/blob/main/cozo-lib-c/example.c>

I've been struggling to link the provided DLLs in the compiler.

With the below code it seems to try and link statically when using the lib 
files,but this way is taking a very long time . Maybe this is because the 
library itself is a hefty 250mb, I assume because it brings with it mysql and 
rocksdb backend by default.
    
    
    import futhark
    import strutils
    # Tell futhark where to find the C libraries you will compile with, and what
    # header files you wish to import.
    importc:
      path "./lib/c"
      "cozo_c.h"
    
    {.passL: "-Llib/static -llibcozo_c".}
    
    proc query(db_id: int32, query: cstring) =
        let empty_params = "{}"
        var res: cstring
        res = cozo_run_query(db_id, query, empty_params, false)
        echo $res
        cozo_free_str(res)
    
    proc main() =
        var db_id: int32
        var err: cstring
        err = cozo_open_db("mem", "", "{}", addr db_id)
        
        if err != nil :
            echo $err
            cozo_free_str(err)
            return
        
        query(db_id, "?[] <- [[1, 2, 3]]")
        
        echo cozo_close_db(db_id)
    
    main()
    
    
    Run

So I have two questions:

>   * How can I adapt this to use DLLs? And how do I link/bind to DLLs in 
> general?
>   * Will using DLLs in this specific case prevent the very slow compile step 
> that seems to occur?
> 


Thanks :)

Reply via email to