tomassedovic / tcod-rs

Rust bindings for libtcod 1.6.3 (the Doryen library/roguelike toolkit)
Do What The F*ck You Want To Public License
229 stars 45 forks source link

option to build libtcod statically? #262

Closed laanwj closed 5 years ago

laanwj commented 6 years ago

It's currently a bit of a pain to run examples and applications using the library at the moment due to the libtcod.so dependency at run time.

I think statically linking the internal libtcod (e.g. as a .a) could avoid this and make the resulting executables self-contained, of course apart from system libraries such as SDL.

tomassedovic commented 6 years ago

I agree, this would be a great usability win.

Unfortunately, I don't really have the time and knowledge to investigate this at the moment. Do you? I'd be happy to help in any way I can and I would love to accept a pull request that implements it.

laanwj commented 6 years ago

Sure!

I can't promise how soon, but I'm willing to look at this.

tomassedovic commented 6 years ago

Awesome, thanks!

laanwj commented 6 years ago

I looked into it, it's easy enough to make it link to an .a instead of an .so, as well as to add println!("cargo:rustc-link-lib=dylib=SDL2"); to specify SDL2 as a dependency for linking libraries.

However, it looks like rust insists on passing the order of the linker arguments as "-l" "SDL2" "-l" "tcod" which is the wrong way around, so I get screens full of symbol errors. Nothing that I tried could make it work.

Oh, never mind, I think I have it, I didn't know pkg_config::find_library("sdl2") would add the library automatically.

tomassedovic commented 5 years ago

The PR above is merged, I'm closing this issue. Thanks so much for doing this @laanwj!