-
Notifications
You must be signed in to change notification settings - Fork 14
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 pre-built library? #26
Comments
After some experimentation, I've come to realise that it makes no sense for this ticket to exist on Instead, we should add a feature flag to |
I was asked to reopen this at PistonDevelopers/glfw-rs#506 . |
Is this being worked on still? |
I haven't done anything but it's still desirable. I think the way to do it is you just add pkg_config to build deps and something like |
So, I tried a simple patch like the one at the bottom. It works in-as-so-far as getting rust_glfw> Building src/lib.rs (glfw)
rust_glfw> Running rustc --crate-name glfw src/lib.rs --out-dir target/lib -L dependency=target/deps --cap-lints allow -L native=/nix/store/5msqd90ci50307ffs5i1avb6k78z6a41-glfw-3.3.8/lib -C opt-level=3 -C codegen-units=1 --remap-path-prefix=/build=/ --extern bitflags=/nix/store/a6bgm020s04nynwnzsbqn10ghwm5gpsf-rust_bitflags-1.3.2-lib/lib/libbitflags-25edeaf30b.rlib --extern glfw_sys=/nix/store/k4sljpxxy6c074kh5l9ajpzlw44ngzz9-rust_glfw-sys-5.0.0+3.3.9-lib/lib/libglfw_sys-29d93d1f86.rlib --extern raw_window_handle_0_5=/nix/store/9fz8iq16hmrv39qg5rjjwh874ld8xbcm-rust_raw-window-handle-0.5.2-lib/lib/libraw_window_handle-2212bb0514.rlib --cfg feature="glfw-sys" --edition 2021 -C metadata=44075dcdb8 -C extra-filename=-44075dcdb8 --crate-type lib -L native=/nix/store/5msqd90ci50307ffs5i1avb6k78z6a41-glfw-3.3.8/lib --color always
rust_glfw> error: could not find native static library `glfw3`, perhaps an -L flag is missing?
rust_glfw> error: aborting due to 1 previous error
error: builder for '/nix/store/5ijyddy0abr8cz7yswk2kj8xhvwqs8yx-rust_glfw-0.55.0.drv' failed with exit code 1;
last 10 log lines:
> Running phase: updateAutotoolsGnuConfigScriptsPhase
> Running phase: configurePhase
> Running cd .
> Running phase: buildPhase
> Building src/lib.rs (glfw)
> Running rustc --crate-name glfw src/lib.rs --out-dir target/lib -L dependency=target/deps --cap-lints allow -L native=/nix/store/5msqd90ci50307ffs5i1avb6k78z6a41-glfw-3.3.8/lib -C opt-level=3 -C codegen-units=1 --remap-path-prefix=/build=/ --extern bitflags=/nix/store/a6bgm020s04nynwnzsbqn10ghwm5gpsf-rust_bitflags-1.3.2-lib/lib/libbitflags-25edeaf30b.rlib --extern glfw_sys=/nix/store/k4sljpxxy6c074kh5l9ajpzlw44ngzz9-rust_glfw-sys-5.0.0+3.3.9-lib/lib/libglfw_sys-29d93d1f86.rlib --extern raw_window_handle_0_5=/nix/store/9fz8iq16hmrv39qg5rjjwh874ld8xbcm-rust_raw-window-handle-0.5.2-lib/lib/libraw_window_handle-2212bb0514.rlib --cfg feature="glfw-sys" --edition 2021 -C metadata=44075dcdb8 -C extra-filename=-44075dcdb8 --crate-type lib -L native=/nix/store/5msqd90ci50307ffs5i1avb6k78z6a41-glfw-3.3.8/lib --color always
> error: could not find native static library `glfw3`, perhaps an -L flag is missing?
>
> error: aborting due to 1 previous error
>
For full logs, run 'nix log /nix/store/5ijyddy0abr8cz7yswk2kj8xhvwqs8yx-rust_glfw-0.55.0.drv'.
error: 1 dependencies of derivation '/nix/store/8i5x0s9pmfp1q5pip7ak0p1njc94zpi2-rust_isim-0.1.0.drv' failed to build We can see the My original patch (which we are using since I made the ticket) didn't have this issue because it bypassed I'm not sure what the right way forward is. Should we just take off diff --git a/Cargo.toml b/Cargo.toml
index 720802e0..b2287c9f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,6 +17,7 @@ path = "lib.rs"
[build-dependencies]
cmake = "0.1"
+pkg-config = "0.3"
[features]
wayland = []
diff --git a/build.rs b/build.rs
index d0a2bde9..53aaeded 100644
--- a/build.rs
+++ b/build.rs
@@ -1,7 +1,15 @@
extern crate cmake;
+extern crate pkg_config;
+
use cmake::Config;
fn main() {
+ if pkg_config::probe_library("glfw3").is_ok() {
+ // We got the library via pkg_config, we don't need to try and build it
+ // below.
+ return;
+ }
+
let mut cfg = Config::new("glfw");
cfg.define("GLFW_BUILD_EXAMPLES", "OFF")
|
PS: In the end we also want X11 to be found by pkgconfig so we end up patching glfw-rs either way... I guess there should be x11-sys dependency that already handles this. |
Wow, thanks for working on this! It's a shame it can't be done right now tho |
It appears
glfw-sys
will always compileglfw
for whatever the target system is.However we control the build system precisely and have the ability to provide it with pre-built
glfw
. It seems a shame/pointless to compile anyway: instead of giving it pre-built library, we instead give it all the tools to build one...A lot of other
*-sys
crates allow specifying existing libraries with things like pkg-config which can also ensure all the libraries are properly presented when linking binaries later on.Is there a reason why glfw needs to be pre-built? I'm a little confused if this is actually a requirement: the README mentions that Windows users can download pre-built glfw binaries. If so, that should imply that it's possible to use pre-compiled libraries, somehow.
The text was updated successfully, but these errors were encountered: