试图在Debian/Ubuntu上安装ruby-odbc gem会导致以下错误;
"ERROR: sql.h not found"
eir*_*irc 31
这种情况也发生在OSX上,所以要拯救:
brew install unixodbc
Run Code Online (Sandbox Code Playgroud)
tom*_*non 25
安装unixodbc-dev软件包,然后再次尝试gem安装
sudo apt-get install unixodbc-dev
gem install ruby-odbc
Run Code Online (Sandbox Code Playgroud)
在 Mac 上,gem 找不到本机包。
brew install unixodbc
Run Code Online (Sandbox Code Playgroud)
查看安装路径:
brew list unixodbc
Run Code Online (Sandbox Code Playgroud)
你会得到类似的东西:
/opt/homebrew/Cellar/unixodbc/2.3.11/.bottle/etc/ (2 个文件) /opt/homebrew/Cellar/unixodbc/2.3.11/bin/dltest /opt/homebrew/Cellar/unixodbc/2.3.11 /bin/isql /opt/homebrew/Cellar/unixodbc/2.3.11/bin/iusql /opt/homebrew/Cellar/unixodbc/2.3.11/bin/odbc_config /opt/homebrew/Cellar/unixodbc/2.3.11/bin /odbcinst /opt/homebrew/Cellar/unixodbc/2.3.11/bin/slencheck /opt/homebrew/Cellar/unixodbc/2.3.11/include/unixODBC/ (2 个文件)/opt/homebrew/Cellar/unixodbc/2.3。 11/include/ (11 个文件) /opt/homebrew/Cellar/unixodbc/2.3.11/lib/libodbc.2.dylib /opt/homebrew/Cellar/unixodbc/2.3.11/lib/libodbccr.2.dylib /opt /homebrew/Cellar/unixodbc/2.3.11/lib/libodbcinst.2.dylib /opt/homebrew/Cellar/unixodbc/2.3.11/lib/pkgconfig/ (3 个文件) /opt/homebrew/Cellar/unixodbc/2.3。 11/lib/(其他 6 个文件)/opt/homebrew/Cellar/unixodbc/2.3.11/share/man/(8 个文件)
将该输出应用于
gem install ruby-odbc -- --with-odbc-dir=[path to unixodbc]
Run Code Online (Sandbox Code Playgroud)
例子:
gem install ruby-odbc -- --with-odbc-dir=/usr/local/Cellar/unixodbc/2.3.11