我正在尝试在ruby-1.9.3-p547下的Mac OS X 10.9上安装ruby-odbc gem,以便与通过ODBC连接到SAP系统的rails 2.3.12应用程序一起使用。
环境
场合
执行
时,gem系统失败了构建gem install ruby-odbc
抱怨无法在
中找到sql.h
ERROR: sql.h not found
然后我尝试通过
告诉gem头安装环境ODBC头的位置gem install ruby-odbc -- --with-odbc-dir=/usr/local/iODBC
但是这仍然失败了以下消息(基本上仍然找不到sql.h头文件)。
此时 - 由于无法建立宝石而陷入困境
This could take a while...
ERROR: Error installing ruby-odbc:
ERROR: Failed to build gem native extension.
/Users/grantsayer/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb --with-odbc-dir=/usr/local/iODBC --with-odbc-include=/usr/local/iODBC/include
checking for version.h... no
checking for sql.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/grantsayer/.rvm/rubies/ruby-1.9.3-p547/bin/ruby
--with-odbc-dir
--with-odbc-include=${odbc-dir}/include
--with-odbc-lib
--without-odbc-lib=${odbc-dir}/lib
ERROR: sql.h not found
extconf failed, exit code 1
答案 0 :(得分:9)
已解决问题。关键是将gem安装为
的命令gem install ruby-odbc -- --with-odbc-dir=/usr/local/iODBC/
此前的关键步骤是按照步骤
重新安装软件堆栈ruby -e" $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ \ curl -sSL https://get.rvm.io | bash -s stable
rvm install ruby-1.9.3
有多个版本,Mac OX版本作为DMG文件提供,用于在应用程序中安装驱动程序管理器,以及构建ruby-odbc gem所需的头文件
http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/Downloads#Mac%20OS%20X
ruby-odbc gem在Ruby ODBC描述。这描述了原始源的构建,但是gem安装生态系统将获得源和构建。
gem install ruby-odbc -- --with-odbc-dir=/usr/local/iODBC/
重要的部分是安装的标头和库的路径,它们通过iODBC安装放入/ usr / local / iODBC。
成功就是当你得到如下所示安装gem的常见快乐消息时:
gem install ruby-odbc -- --with-odbc-dir=/usr/local/iODBC/
Building native extensions with: '--with-odbc-dir=/usr/local/iODBC/'
This could take a while...
Successfully installed ruby-odbc-0.99995
Enclosing class/module 'Modbc' for class Object not known
Enclosing class/module 'Modbc' for class Environment not known
Enclosing class/module 'Modbc' for class Database not known
Enclosing class/module 'Modbc' for class Statement not known
Enclosing class/module 'Modbc' for class Column not known
Enclosing class/module 'Modbc' for class Parameter not known
Enclosing class/module 'Modbc' for class DSN not known
Enclosing class/module 'Modbc' for class Driver not known
Enclosing class/module 'Modbc' for class Error not known
Enclosing class/module 'Modbc' for class Date not known
Enclosing class/module 'Modbc' for class Time not known
Enclosing class/module 'Modbc' for class TimeStamp not known
Installing ri documentation for ruby-odbc-0.99995
1 gem installed
答案 1 :(得分:3)
我在macOs Sierra 10.12上遇到了类似的问题
我做了什么:
brew install libiodbc
然后检查已安装软件包的版本(应该像libiodbc-3.52.12),如果在以下命令中有不同的更改:
gem install ruby-odbc -- --with-odbc-dir=/usr/local/Cellar/libiodbc/3.52.12/
祝你好运。