erickt / rust-zmq

Rust zeromq bindings.
Apache License 2.0
887 stars 190 forks source link

x86_64-unknown-linux-musl failing #248

Closed skyne98 closed 5 years ago

skyne98 commented 5 years ago

Hey there, is there a way to compile rust-zmq for a musl target (for alpine, in my case)?

Trying to compile an example leads to:

error: failed to run custom build command for `zmq-sys v0.9.0 (/mnt/c/Users/oleksii.halahan/Documents/Experiments/rust-zmq/zmq-sys)`
process didn't exit successfully: `/mnt/c/Users/oleksii.halahan/Documents/Experiments/rust-zmq/target/release/build/zmq-sys-4a61f117fb780586/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Unable to locate libzmq:
Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override', zmq-sys/build.rs:31:17
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed

The release build works just fine without a target specified. My environment is a WSL system running Ubuntu 18.04. libzmq3-dev is installed, as well as musl tools (musl-gcc is present).

Thanks!

skrap commented 5 years ago

You'll need to make the cc crate happy: https://github.com/alexcrichton/cc-rs#external-configuration-via-environment-variables Alternatively, if the issue is that it can't find zmq due to location issues, you could set the LIBZMQ_PREFIX env var (e.g. LIBZMQ_PREFIX=/usr/local/ if the zmq headers and lib are in /usr/local/include and /usr/local/lib, respectively). If you would rather specify separately, LIBZMQ_INCLUDE_DIR and LIBZMQ_LIB_DIR are available as well.

skyne98 commented 5 years ago

@skrap, thanks for your recommendations! I will definitely play around with them and try to figure out a way to build it. However, I think that it would be better if rust-zmq was able to build itself for such targets out of the box. Maybe I can post my progress and findings here and later they can be incorporated into the crate?

skyne98 commented 5 years ago

@skrap, I think this can be closed now. In case someone tries that in the future -- just follow the instructions in the error and try setting PKG_CONFIG_ALLOW_CROSS=1

skrap commented 5 years ago

@skyne98 I'm neither the project owner nor the originator; I have no bug closing power here :) I'm glad you figured out a solution!

skyne98 commented 5 years ago

@skrap, oh, sorry, inferred that a first person to answer should be somehow directly related to the administration of the project :D

skyne98 commented 5 years ago

@erickt, I think you are the one to ask?

rotty commented 5 years ago

@erickt and myself have bug-closing power, but it seems both of us are busy with other things. I hope I can devote at least a minimal consistent amount of time to maintaining this crate in the future, though.