Ruby on Rails 在 Debian 上安装 mysql2 gem 时找不到 -lssl 和 -lcrypto

Ruby on Rails cannot find -lssl and -lcrypto when installing the mysql2 gem on Debian

我正在尝试将 rails 上的 ruby 与 MariaDB 连接。但是由于某种原因,当我尝试安装 mysql2 gem 时,出现了这个错误:

/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto

rails ruby 我缺少什么 SSL/Crypto 库?

我找不到其他人遇到同样的问题。

我遇到的错误:

"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -
I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -
I/usr/include/mysql -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fdebug-prefix-
map=/build/ruby2.3-yge53O/rub$
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */

"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -
I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -
I/usr/include/mysql -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fdebug-prefix-map=/build/ruby2.3-yge53O/rub$
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */

您似乎缺少 libssl-dev 包。尝试 运行:

sudo apt-get update
sudo apt-get install libssl-dev

包安装完成后,再次尝试安装 gem。