-
Notifications
You must be signed in to change notification settings - Fork 17
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
Using from a single binary #12
Comments
What use case are you thinking of?
I haven't blogged about it much, but it's possible to statically link a sqlite extension written with You can also use it to compile Is that the kind of thing you're going for? |
@asg017 thank you so much for such a detailed answer! I was thinking of doing this:
|
Yeah, I think statically compiling an extension written with I'm not too sure about the I'll probably blog about statically linking SQLite extension in the next few weeks, and will also include an end-to-end example of statically linking in this repo soon as well. |
That being said |
@asg017 thank you for all the info! I wrote sqlite-hashes crate for the static usacase using rusqlite, but I do hope that I can somehow support dynamic lib generation as well, e.g. with a feature flag of sorts. |
I'm also interested in this. I have a dynamically loaded runtime extension that I want to switch to a statically linked runtime loadable extension (see section 6 in that link). I'm currently using rusqlite-le which is mentioned in https://github.com/phiresky/sqlite-zstd. The source and any mention of that have vanished. It seems to only support dynamically loaded extensions. In particular I get issues around a NULL sqlite3_api so I think it or the libsqlite3-sys bindings are doing something whacky. I'm able to link it statically with I saw you in your docs the |
I don't have a great standalone example of this yet, but compiling with To have a In rust, see this issue for an example of importing an extension written with Though do note, I've only been able to successfully do this on Linux/MacOS. I ran into some linking errors in Windows that I couldn't figure out. Feel free to share the errors that you got when trying to statically link your extension. It can be tricky in general, there's a lot of CFLAGS and LDFLAGS you have to get right. I usually have to define |
Yeah it's quickly turning into a cesspool of linking issues when I try. 😢 |
Can you share some error messages that you see? Along with the platform you are compiling on (Macos/linux/arm etc.), the sqlite-loadable version you're on, and the compiler flags you've tried? Also, does your Rust project have any additional dependencies that reply on other C libraries? |
I think like @nyurik I haven't gone down the path of building on this crate. I have built on rusqlite. I believe the linker issues I'm having are not related to rusqlite. I'm currently making use of what is described in https://ricardoanderegg.com/posts/extending-sqlite-with-rust/ to create a dynamically loadable extension with rusqlite. I will be very interested to read your blog post if it talks about statically linking such an extension in to an executable. The branch of rusqlite referred to in the link has an example of statically linking an extension into a shared object that is loaded dynamically, it's not quite the same. |
Here is the error if it means anything to you:
|
From a deployment/usage perspective, it would be ideal if the resulting executable could contain both the statically-linked sqlite, as well as any extensions. Do you see any way to achieve this?
The text was updated successfully, but these errors were encountered: