More than 5 years have passed since last update.

El Capitanでソースをコンパイルしたときにopensslのエラーが出た場合の対処方法

Last updated at Posted at 2015-11-29



$ ./configure
# 省略
Configuration for libimobiledevice 1.2.0:

  Install prefix: .........: /usr/local
  Debug code ..............: no
  Python bindings .........: no
  SSL support backend .....: OpenSSL

  Now type 'make' to build libimobiledevice 1.2.0,
  and then 'make install' for installation.

$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in common
  CC       socket.lo
  CC       thread.lo
  CC       debug.lo
In file included from debug.c:36:
../src/idevice.h:30:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
1 error generated.
make[2]: *** [debug.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2


  • El CapitanではOpenSSLヘッダが提供されなくなっている
  • Homebrewでopensslをインストールし、brew link openssl --forceのコマンドを実行すると良い

brew link 〜のコマンドを実行しても、残念ながらエラーは変わりません。


.bash_profile に以下のパスを追加したところ、コンパイルが通るようになりました。

export PATH=/usr/local/opt/openssl/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/opt/openssl/lib:$LD_LIBRARY_PATH
export CPATH=/usr/local/opt/openssl/include:$CPATH
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH

なお、パスを追加していても、brew link openssl --forceを実行していない環境では、以下のエラーが発生してコンパイルに失敗しました。

$ make
# 省略
Undefined symbols for architecture x86_64:
  "_ERR_remove_thread_state", referenced from:
      _internal_idevice_deinit in idevice.o
      _idevice_connection_enable_ssl in idevice.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libimobiledevice.la] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

brew link 〜の実行とパスの追加の両方が必要だったようです。

brew link openssl --forceは、現在は使えなくなっています。

$ brew link openssl --force
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib


  • Mac OS X 10.11.6 El Capitan
  • MacBook Pro (Retina, 13-inch, Late 2013)
  • Xcode 8.2.1
  • Homebrew 1.2.0 (git revision 922c8; last commit 2017-05-02)
  • OpenSSL 1.0.2k 26 Jan 2017
  • libimobiledevice-1.2.0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up