-
Notifications
You must be signed in to change notification settings - Fork 15
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
Link Library #8
Comments
I tried this import Alloy.C
open scoped Alloy.C
#eval Alloy.C.modifyLocalServerConfig (·.addFlag "-lsqlite3")
alloy c include <lean/lean.h> <sqlite3.h> <stdio.h>
alloy c extern
def sqliteversion : BaseIO UInt32 :=
printf("%s\n", sqlite3_libversion())
return lean_io_result_mk_ok(lean_box(0)) But then lake gets stuck at |
I tried compiling without alloy and there the same error appears. I found this other library that also needs to link https://github.com/arthurpaulino/LeanMySQL/blob/master/lakefile.lean . They added moreLinkArgs to the package in lake-file, which seems necessary for the final linking (?) . I suppose now i can try, whether this will also help when using alloy.
|
@drcicero Hello! To link to a shared library, specifying the linking flags via For link arguments, hard-coding the location of the library (e.g.,
Unfortunately, path (2) is complicated to accomplish at present, so it might not be wise to peruse. (However, if you are curious, LeanCopilot's |
Thanks for the response! I got surprisingly far without alloy for now, but I'm intrigued by your comment on avoiding platform-specificity. Option two sounds like more work, I will ignore that for now. Option one was:
Do you mean LIBRARY_PATH (compile-time) or LD_LIBRARY_PATH (run-time)? I just tried removing the platform-specific Do you have an example for how this could work?
EDIT: For example when using just
Maybe I'm doing something stupid :) |
There is mixed of news here. The good news is that is does seem to be successfully linking to a version sqlite3 installed in your systems library path. The neutral news is that it appears that version of sqlite3 needs pthread, and the potentially bad news, is that it possibly needs a different pthread than the one used by Lean? I am not confident I can provide you good advice on what exactly is needed here without trying this myself on a Linux system. I'll see if I can find some time to do so, but, unfortunately, I am not sure I promise I will. In general, though, you are on the write track, you just need to find the right set of arguments to get your executable to link without errors. You can also run with |
Thanks for the input.
Of course you don't need to do anything, I'm just randomly asking someone on the internet :) In any case, I found this and this. Sebastian Ullrich wrote in both cases:
But that didnt work for me. I detailed my endeavor here: https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Linking.20a.20C.20library/near/429369692 . Maybe someone has an idea.
-v to what? |
Sorry, |
Hi, alloy sounds nice!
I wonder, how does one link a library -- in particular, with gcc for example, I would add the flag
-lsqlite3
to link the library and make its symbols available. How would I add a-l
flag using alloy?For example
sudo apt install sqlite3-dev
The text was updated successfully, but these errors were encountered: