sfackler / rust-openssl

OpenSSL bindings for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Faild build On OSX 10.11(Elp)

imiskolee opened this issue · comments

failed to run custom build command for openssl-sys v0.6.4
Process didn't exit successfully: /Users/misko/developer/rust_projects/aws-simple-sdk.rs/target/debug/build/openssl-sys-149f6ef08ad7404d/build-script-build (exit code: 101)
--- stdout
cargo:rustc-link-search=native=/usr/lib
cargo:rustc-link-lib=ssl
cargo:rustc-link-lib=crypto
cargo:rustc-link-lib=z
TARGET = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
CARGO_MANIFEST_DIR = Some("/Users/misko/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.6.4")
OUT_DIR = Some("/Users/misko/developer/rust_projects/aws-simple-sdk.rs/target/debug/build/openssl-sys-149f6ef08ad7404d/out")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
debug 0
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
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
running: "cc" "-O0" "-c" "-ffunction-sections" "-fdata-sections" "-g" "-m64" "-fPIC" "-o" "/Users/misko/developer/rust_projects/aws-simple-sdk.rs/target/debug/build/openssl-sys-149f6ef08ad7404d/out/src/openssl_shim.o" "/Users/misko/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.6.4/src/openssl_shim.c"

command did not execute successfully, got: exit code: 1

--- stderr
/Users/misko/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.6.4/src/openssl_shim.c:1:10: fatal error: 'openssl/hmac.h' file not found

include <openssl/hmac.h>

     ^

1 error generated.
thread '

' panicked at 'explicit panic', /Users/misko/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.13/src/lib.rs:510

I'm also seeing the same issue on OSX 10.11

failed to run custom build command for `openssl-sys v0.6.4`
Process didn't exit successfully: `/Users/robertlong/workspace/eve/runtime/target/debug/build/openssl-sys-765ddf9de3c5179c/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-search=native=/usr/lib
cargo:rustc-link-lib=ssl
cargo:rustc-link-lib=crypto
cargo:rustc-link-lib=z
TARGET = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
CARGO_MANIFEST_DIR = Some("/Users/robertlong/.multirust/toolchains/nightly-2015-08-10/cargo/registry/src/github.com-0a35038f75765ae4/openssl-sys-0.6.4")
OUT_DIR = Some("/Users/robertlong/workspace/eve/runtime/target/debug/build/openssl-sys-765ddf9de3c5179c/out")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
debug 0
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
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
running: "cc" "-O0" "-c" "-ffunction-sections" "-fdata-sections" "-g" "-m64" "-fPIC" "-o" "/Users/robertlong/workspace/eve/runtime/target/debug/build/openssl-sys-765ddf9de3c5179c/out/src/openssl_shim.o" "/Users/robertlong/.multirust/toolchains/nightly-2015-08-10/cargo/registry/src/github.com-0a35038f75765ae4/openssl-sys-0.6.4/src/openssl_shim.c"


command did not execute successfully, got: exit code: 1



--- stderr
/Users/robertlong/.multirust/toolchains/nightly-2015-08-10/cargo/registry/src/github.com-0a35038f75765ae4/openssl-sys-0.6.4/src/openssl_shim.c:1:10: fatal error: 'openssl/hmac.h' file not found
#include <openssl/hmac.h>
         ^
1 error generated.
thread '<main>' panicked at 'explicit panic', /Users/robertlong/.multirust/toolchains/nightly-2015-08-10/cargo/registry/src/github.com-0a35038f75765ae4/gcc-0.3.11/src/lib.rs:514
stack backtrace:
   1:        0x10ff0f1b5 - sys::backtrace::write::h6ddc342d792b0e00eys
   2:        0x10ff18740 - panicking::on_panic::h958ebf4d6905d53emex
   3:        0x10fed1762 - rt::unwind::begin_unwind_inner::hbd872a23a0e4a7d76Hw
   4:        0x10fe2c9cc - rt::unwind::begin_unwind::h4878656591332600981
   5:        0x10fe25ed0 - fail::h760db72685f0b7d0COa
   6:        0x10fe36058 - run::h77877c702f7c820fKHa
   7:        0x10fe2f9a9 - Config::compile_object::h7f3ab7454f729dd6ema
   8:        0x10fe293fb - Config::compile::h7653fa0ba387c0b8Rha
   9:        0x10fdf88a7 - build_openssl_shim::h5076206d24a8328fSfa
  10:        0x10fdf1043 - main::h53a555fd2c70138diaa
  11:        0x10ff17fad - __rust_try
  12:        0x10ff196cd - rt::lang_start::ha6eaa4ada71a9cdbh9w
  13:        0x10fe0064e - main

It looks like OSX 10.11 doesn't ship with openssl anymore. You'll need to install your own copy I guess.

i fix it as:
first,i compliing openssl-sys success.
than, compliing openssl it success.

commented

This worked for me (when building Servo):

export OPENSSL_INCLUDE_DIR=/usr/local/Cellar/openssl/1.0.2d_1/include/

I install the openssl using Homebrew, and the this works for me:
export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include

I had to do both of the following to get it to work, rather than just the first one (fish, not bash). Not sure what is up with that, but if the above by itself doesn't work, try this!

set -x OPENSSL_INCLUDE_DIR /usr/local/opt/openssl/include
set -x OPENSSL_ROOT_DIR /usr/local/opt/openssl
$ brew info openssl
openssl: stable 1.0.2d (bottled)

I also had success doing brew link --force openssl - that was enough to get Servo building for me again. The OSX update perhaps reset a bunch of symlinks?

OSX doesn't ship OpenSSL headers anymore starting with El Capitan.

Same observation as #255 (comment), relinking openssl with brew fixed the build for me as well.

But probably it's not the best solution to this problem, as brew doctor produces a new warning now:

$ brew doctor
[...]
Warning: Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
`brew link <formula>` will cause other formulae to detect them during
the `./configure` step. This may cause problems when compiling those
other formulae.

Binaries provided by keg-only formulae may override system binaries
with other strange results.

You may wish to `brew unlink` these brews:
    openssl

Same problem here on Mac OS X 10.11 (El Capitan). Running brew link --force openssl (as mentioned elsewhere in this thread) solved the problem, and things compiled beautifully.

Hey folks, same issue. Unfortunately the Homebrew solution didn't work for me. Anyone have any other ideas?

brew link --force openssl worked for me on OS X 10.11. Might be good to mention this in Servo's Readme.

thinks.is fix.

commented

I tried all the suggestions in this ticket, I am using homebrew via boxen so my openssl is installed under /opt/boxen/homebrew/Cellar/openssl/1.0.2e/include/ on OS X 10.11.2 (El Capitan) and this solved it for me

export C_INCLUDE_PATH=/opt/boxen/homebrew/Cellar/openssl/1.0.2e/include

I am posting this in an effort to help any others seeking to find a solution

I fix it as:
export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include
export DEP_OPENSSL_INCLUDE=/usr/local/opt/openssl/include

I have the same problem on Ubuntu 14.04, any ideas what to do there?

I have this:
$ /usr/bin/openssl version
OpenSSL 1.0.1f 6 Jan 2014

Though which openssl points to my Anaconda installation, /home/arjan/Programs/anaconda3/bin/openssl (OpenSSL 1.0.1k 8 Jan 2015).

Never mind, my issue was while installing Eve, and there I found a solution, sudo apt-get install libssl-dev.

As iszak mentioned, I too had to export C_INCLUDE_PATH on OS X 10.11.2, just exporting OPENSSL_INCLUDE_DIR had no effect.

@herrernst Try cargo clean and then build with OPENSSL_INCLUDE_DIR and OPENSSL_LIB_DIR set. See #316 for further commentary on why you should set both.

@andrewtj You're right, thanks.

This is still an issue; it was not helped by brew link.

DEP_OPENSSL_INCLUDE=$(brew --prefix openssl)/include cargo run did the trick.

@tamird did you cargo clean after brew linking?

I hadn't. I just repeated the procedure; cargo clean after brew link indeed fixed this. I don't quite understand why, though. Environment state is being compiled into the build script?

openssl-sys's build script determines the location of openssl's headers and Cargo will pass them onto dependent crates via the DEP_OPENSSL_INCLUDE environment variable. If the headers are missing, openssl-sys will compile successfully but forward the wrong vlaue of DEP_OPENSSL_INCLUDE along to downstream crates. If we force openssl-sys to rebuild, it'll pass along the correct configuration.

Worked for me:

export C_INCLUDE_PATH=/usr/local/Cellar/openssl/1.0.2f/include

No combination of the above suggestions seem to be working for me... I either get a link error for openssl/hmac.h in openssl-sys-extras v0.7.6 or a link error for openssl/ssl.h in openssl v0.7.6

Fixed with Alsmile's recommendation:

export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include 
export DEP_OPENSSL_INCLUDE=/usr/local/opt/openssl/include

Fixed with Alsmile's recommendation using macports:

export DEP_OPENSSL_INCLUDE=/opt/local/include         
export OPENSSL_INCLUDE_DIR=/opt/local/include         

I couldn't get any suggestions to work, but a clean install of OSX 10.11 with brew link --force openssl did fix this for me.

I had to update CLFAGS with

export CFLAGS="-I /usr/local/opt/openssl/include"

Thanks guys. I first tried the brew link to no avail, but compilation succeeded after the exports.

brew link --force openssl
export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include 
export DEP_OPENSSL_INCLUDE=/usr/local/opt/openssl/include

This was on Yosemite 10.10.5

@larsbergstrom thank you very much, your advice about brew link --force openssl is still valid, even in Sierra. @sfackler please consider to add this line as 4 line into readme instruction.

Upstream Homebrew seems to refuse to link it anymore. :(

Yay!

I'm working on adjusting some APIs to hopefully allow openssl to build without requiring headers to be installed for the basic feature set. Should make it "just work" on OSX.

upstream homebrew refuse to link.

brew --version
Homebrew 0.9.9 (git revision b8ce1; last commit 2016-08-06)
Homebrew/homebrew-core (git revision fea8; last commit 2016-08-06)

I use macOS Sierra and zsh
i add two line in to .zshrc and it work perfectly

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

One solution would be to check for the OS version and if it fails then print the paragraph from the Readme.md#L34-L40 that explains how to build under OSX 10.11. This is how other people deal with this kind of problem until there is a real fix.

This would have certainly saved me 5 minutes of my life, and after checking the options, i conclude that exporting Env vars is the most elegant solution in the moment.

Yep, that would definitely be a reasonable thing to do. Want to open a PR?

I am fairly new to Rust and it is 4 o'clock in the morning.

How would I catch the c compiler exit() return value from the build.rs main().
Is that even possible, otherwise I would check for the pkg-config path and then
check for the environment variables, if both is not to be found panic.

I just checked my 10.9 installation and found

/usr/local/Cellar/openssl/1.0.2d_1/include/openssl/ssl.h
/usr/local/Cellar/openssl/1.0.2f/include/openssl/ssl.h
/usr/local/Cellar/openssl/1.0.2h_1/include/openssl/ssl.h

so pkg-config then check if ssl.h is to be found in any of

pkg-config include paths

/usr/include/openssl/ssl.h 
/usr/local/include/openssl/ssl.h

now check the env for

OPENSSL_INCLUDE_DIR
OPENSSL_LIB_DIR

if all of that returned false or empty then panic.

Any suggestion on how to catch the llvm error.

For lurkers, on El Capitan (osx) I needed to add the following in my .bash_profile:

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

This worked for me on MacPorts:

export OPENSSL_INCLUDE_DIR=/opt/local/include
export OPENSSL_LIB_DIR=/opt/local/lib

I do seem to be running into some kind of conflict with libgit2_sys (rust-lang/cargo#3538); I've seen similar bugs opened but not yet sure what the actual cause is. The problem does go away when using brew instead of macports.

If you're using the Nix package manager, I found that the following works:

nix-shell -p openssl pkg-config