crumblingstatue / rust-openmpt-sys

Rust sys bindings for libopenmpt
https://lib.openmpt.org/doc/libopenmpt_c_overview.html
3 stars 3 forks source link

Static linking support #1

Open vivyir opened 3 years ago

vivyir commented 3 years ago

Hi! I'm actively working on developing a rust port to one of my shell scripts (phnixir/trackergrab), however every time i build it using musl and the openmpt crate which uses this crate as a dependency AND this crate only links dynamically and because of that no matter how i build i always have a dynamically linked executable.

Could you provide the bindgen files you used to generate this? Since it seems this project has been abandoned I don't want to bother you and instead add support for building the bindings locally myself, Thank you!

crumblingstatue commented 3 years ago

Hi! It's true that I haven't been working on this crate for years, but that's because I didn't have a need to, because no one requested anything and it's working for my purposes. I can try and add static linking support. I'm not sure what you mean by bindgen files, I just ran bindgen on the openmpt header files.

vivyir commented 3 years ago

Static linking support would be amazing! Since i never really used bindgen first-hand i thought it needed a big build.rs file since that's how I've seen other projects do it, now that I actually tested it it makes more sense.

crumblingstatue commented 3 years ago

Hmm... The main problem is that openmpt is written in C++, so it can't be easily linked statically. rustc uses a C compiler for linking, which doesn't link the C++ standard library for example. This might need a lot of work and experimentation.

crumblingstatue commented 3 years ago

See also the section about statically linking here https://lib.openmpt.org/doc/libopenmpt_c_overview.html#libopenmpt_c_staticlinking

crumblingstatue commented 3 years ago

The easiest thing to do would be to let the user provide the location to a statically linked libopenmpt through an environment variable, and try to link against that, plus the C++ standard library through a crate like link-cplusplus.

I don't feel particularly motivated to work on this right now, but if you feel up to the challenge, I can try and answer any questions you might have trying to implement this.