openssl/ssl.h'文件未找到

刚安装El Capitan,不能安装gem eventmachine 1.0.7openssl1.0.2a-1。尝试使用--with-ssl-dir,但它似乎被忽略了。

也报告给他们的github回购

任何建议都非常感谢。谢谢。

$ ls /usr/local/Cellar/openssl/1.0.2a-1/include/openssl/ssl.h
/usr/local/Cellar/openssl/1.0.2a-1/include/openssl/ssl.h


$ gem install eventmachine -v '1.0.7' -- --with-ssl-dir=/usr/local/Cellar/openssl/1.0.2a-1/include
/Users/pain/.rbenv/versions/2.1.2/bin/ruby -r ./siteconf20150612-56154-1hsjz2n.rb extconf.rb --with-ssl-dir=/usr/local/Cellar/openssl/1.0.2a-1/include
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for rb_thread_fd_select()... yes
checking for rb_fdset_t in ruby/intern.h... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue... yes
checking for clock_gettime()... no
checking for gethrtime()... no
creating Makefile


make "DESTDIR=" clean


make "DESTDIR="
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:116:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
^
1 error generated.
make: *** [binder.o] Error 1


make failed, exit code 2
66809 次浏览
$ gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
Building native extensions with: '--with-cppflags=-I/usr/local/opt/openssl/include'
This could take a while...
Successfully installed eventmachine-1.0.8
1 gem installed

你也可以这样设置捆绑器,但我认为这是肤浅的

bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include

当使用bundler和homebrew时:

$ bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include
$ bundle install
brew link --force openssl

然后:

gem install eventmachine

它还修复:

  • Gem安装开销
  • 包安装
  • Rake和rails任务

注:你可能需要再次删除并运行brew install openssl

这个问题是因为苹果已经从OSX中删除了openssl(在El Captain版本中)

如果你将EventMachine作为另一个gem的依赖项安装,请确保在手动安装gem时指定正确的版本:

gem install eventmachine -v 1.0.5 -- --with-cppflags=-I$(brew --prefix openssl)/include

然后你可以安装你最初试图安装的gem:

gem install mailcatcher

另一种选择是为你的整个用户配置文件添加一个捆绑器配置项,就像这样:

cd ~
bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include

它会在你的主目录中创建一个.bundle/config文件,然后在你运行bundle install时在你的所有项目中使用。

gem pristine eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include

质朴删除旧的宝石并重新编译它。

cpp flags选项允许编译器找到openssl头文件。

如果你喜欢抽象cpp标志参数,你可以这样做:

PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig"

你也可以添加版本,如果你喜欢:

gem pristine eventmachine -v '1.0.4' -- --with-cppflags=-I/usr/local/opt/openssl/include

我试图安装v 1.0.3,这对我来说是有效的。

gem install eventmachine -v '1.0.3' -- --with-cppflags=-I/usr/local/opt/openssl/include

这些讨论非常有帮助:https://github.com/eventmachine/eventmachine/issues/602

这假设机器已经通过brew安装了openssl。

这为我解决了问题:

PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig" gem install eventmachine -v "1.0.8"

来源:https://github.com/sj26/mailcatcher/issues/254

这对我很管用

    gem install eventmachine -v '1.0.7' -- --debug --backtrace --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib
Building native extensions with: '--debug --backtrace --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib'
This could take a while...
Successfully installed eventmachine-1.0.7
Parsing documentation for eventmachine-1.0.7
Installing ri documentation for eventmachine-1.0.7
Done installing documentation for eventmachine after 9 seconds
1 gem installed

在我能够成功安装这个宝石之前,我必须做几件事。这些可能适用于你,所以在这里列出它们-

1.) got off the corporate-VPN 或者你可能不得不打开代理设置

2)。PKG_CONFIG_PATH设置为-

echo $PKG_CONFIG_PATH
/usr/local/opt/openssl/lib/pkgconfig

3.)必须在bash_profile中添加以下到$PATH(在我的情况下~/.zshrc)

export PATH="/usr/local/opt/openssl/bin:$PATH"

4)。另请注意,与我在这篇SO帖子中得到的一些答案相反,以及在github-eventmachine上的这个线程,我无法安装eventmachine

gem install eventmachine -v '1.0.7' -- --debug --backtrace --with-cppflags=-I/usr/local/include --with-ldflags=-L/usr/local/lib
Fetching: eventmachine-1.0.7.gem (100%)
Building native extensions with: '--debug --backtrace --with-cppflags=-I/usr/local/include --with-ldflags=-L/usr/local/lib'
This could take a while...
ERROR:  Error installing eventmachine:
ERROR: Failed to build gem native extension.

在指定openssl位置时,似乎/usr/local/opt/openssl/include是正确的位置,而不是/usr/local/include

杰基尔和菲什:

gem install jekyll -- --with-cppflags=-I(brew --prefix openssl)/include

这个看起来像是最近的问题:https://github.com/eventmachine/eventmachine/issues/936

我在macOS 12.3.1上用以下方法解决了这个问题:

M1马克斯:

gem install eventmachine -- --with-openssl-dir=/opt/homebrew/Cellar/openssl@1.1/1.1.1n/

英特尔:

gem install eventmachine -- --with-openssl-dir=/usr/local/Cellar/openssl@1.1/1.1.1n/

这为我安装了它:

gem install eventmachine -- --with-openssl-dir=/usr/local/opt/openssl@1.1

我从eventmachine Github回购得到它。显然,OpenSSL工具在某个时候从MacOS中移动/删除了。

在我的例子中,我想安装其他依赖于eventmachine的东西(mailcatcher)。我在上面的命令中用mailcatcher替换了eventmachine

截至2022年,安装eventmachine的方法(假设brew install openssl已经成功安装)是:gem install eventmachine -- --with-cppflags=-I/opt/homebrew/opt/openssl/include

注意,包含目录已经移动。

我遇到了同样的eventmachine问题,上面的答案对我不起作用,最后用给定的openssl版本重新安装ruby:

rvm reinstall 3.1.2 --with-openssl-dir=/usr/local/opt/openssl@3

对于openssl@3和Homebrew,它通过运行以下命令工作:

gem install eventmachine -- --with-openssl-dir=/usr/local/opt/openssl@3/bin/openssl

注意结尾的/bin/openssl对我来说是不同的。