inre / rust-mq

RustMQ is the MQTT client written on pure Rust.
MIT License
190 stars 28 forks source link

Openssl failures on mac #28

Closed gorup closed 3 years ago

gorup commented 6 years ago

HellO! When attempting to build this on Mac Sierra (10.12.6) I ran into the following issue:

$ cargo build                                                                                                                                                                                 
   Compiling openssl v0.7.14
   Compiling openssl-sys-extras v0.7.14
error: failed to run custom build command for `openssl v0.7.14`
process didn't exit successfully: `/Users/gorup/Dev/rust/toby/target/debug/build/openssl-dcf8b662fbd9cabe/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-apple-darwin")
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
HOST = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
DEBUG = Some("true")
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-m64" "-Wall" "-Wextra" "-o" "/Users/gorup/Dev/rust/toby/target/debug/build/openssl-f2716e2019382eec/out/src/c_helpers.o" "-c" "src/c_helpers.c"
cargo:warning=src/c_helpers.c:1:10: fatal error: 'openssl/ssl.h' file not found
cargo:warning=#include <openssl/ssl.h>
cargo:warning=         ^~~~~~~~~~~~~~~
cargo:warning=1 error generated.
exit code: 1

--- stderr
thread 'main' panicked at '

Internal error occurred: Command "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-m64" "-Wall" "-Wextra" "-o" "/Users/gorup/Dev/rust/toby/target/debug/build/openssl-f2716e2019382eec/out/src/c_helpers.o" "-c" "src/c_helpers.c" with args "cc" did not execute successfully (status code exit code: 1).

', /Users/gorup/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.54/src/lib.rs:1670:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `openssl-sys-extras v0.7.14`
process didn't exit successfully: `/Users/gorup/Dev/rust/toby/target/debug/build/openssl-sys-extras-2793cad237f238db/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-apple-darwin")
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
HOST = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
DEBUG = Some("true")
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-m64" "-Wall" "-Wextra" "-o" "/Users/gorup/Dev/rust/toby/target/debug/build/openssl-sys-extras-dad78d7a0ee72c91/out/src/openssl_shim.o" "-c" "src/openssl_shim.c"
cargo:warning=src/openssl_shim.c:1:10: fatal error: 'openssl/hmac.h' file not found
cargo:warning=#include <openssl/hmac.h>
cargo:warning=         ^~~~~~~~~~~~~~~~
cargo:warning=1 error generated.
exit code: 1

--- stderr
thread 'main' panicked at '

Internal error occurred: Command "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-m64" "-Wall" "-Wextra" "-o" "/Users/gorup/Dev/rust/toby/target/debug/build/openssl-sys-extras-dad78d7a0ee72c91/out/src/openssl_shim.o" "-c" "src/openssl_shim.c" with args "cc" did not execute successfully (status code exit code: 1).

', /Users/gorup/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.54/src/lib.rs:1670:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

I solved the issue by adding

export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include
export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib
export DEP_OPENSSL_INCLUDE=`brew --prefix openssl`/include

to my ~/.zshrc.

I found this solution on another rust package, rust-openssl

Perhaps you could implement a fix for this, or put it in the README? Thx