-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage docs for dynamic libraries #88
Comments
You're very close, the only thing missing is a tiny bit of C linking experience. I dropped the 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 "."
"cozo_c.h"
{.passL: "-L. -lcozo_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() Then it's a simple |
This could definitely be documented better though, so I'm keeping this open |
Thanks for going over this! I got it working on Windows as you described, but only by keeping the files in root. Is there a way I can explicitly pass a flag to the compiler to search lib/dyn, instead? I tried |
You can tell the compiler to look for the dynamic library elsewhere by changing what you pass to |
Hi - I'm trying to follow your example but using a dll. I run into a wall both statically linking and calling a dll library for CozoDB.
https://github.com/cozodb/cozo/blob/main/cozo-lib-c/cozo_c.h
The api is very small so would be a good test case for learning futhark.
Passing a linker pragma seems to hang for a long time then posts
corrupt .drectve
errors.Trying to using loadLib() causes unknown function errors though I might be using it wrong:
Do you see where I could be going wrong? Including some usage docs in the readme (basically a mini tutorial for each scenario - header only, source/header, static lib, dynamic library) would be very useful!
Thanks
The text was updated successfully, but these errors were encountered: