gem install 找不到头文件
遵循 talib_ruby 的 github README:
sudo port install ta-lib
完成。接下来就是麻烦开始的地方。
sudo env ARCHFLAGS="-arch PLATFORM" gem install talib_ruby -- --with-talib-include=ABSOLUTE_PATH_TO_TALIB_HEADERS --with-talib-lib=ABSOLUTE_PATH_TO_TALIB_LIBS
我相信此安装失败,因为显然它找不到
talib.c:2:25: error: ta_abstract.h: No such file or directory
.
.
.
many more errors
我包含在 .bash_profile 文件中的 ta_abstract.h 文件,如下所示:
export ABSOLUTE_PATH_TO_TALIB_HEADERS=/opt/local/var/macports/software/ta-lib/0.4.0_0/opt/local/include/ta-lib
export ABSOLUTE_PATH_TO_TALIB_LIBS=/opt/local/var/macports/software/ta-lib/0.4.0_0/opt/local/lib
事实上,ta_abstract.h 文件位于我在 ABSOLUTE_PATH 变量赋值中所说的位置。
什么给?
更新:
当其他方法都失败时,与 gem 作者的电子邮件通信可能会有所帮助。他建议在安装时传递实际路径,而不是导出 ABSOLUTE_PATH。除了显式传入 ARCHFLAGS="-arch x86_64"(适用于 Snow Leopard)之外。安装仍然失败,但现在是因为 talib.c 文件及其中的某些函数存在问题。
Following along the github README for talib_ruby:
sudo port install ta-lib
Complete. Next is where the trouble begins.
sudo env ARCHFLAGS="-arch PLATFORM" gem install talib_ruby -- --with-talib-include=ABSOLUTE_PATH_TO_TALIB_HEADERS --with-talib-lib=ABSOLUTE_PATH_TO_TALIB_LIBS
This install fails I believe because apparently it cannot find the ta_abstract.h file
talib.c:2:25: error: ta_abstract.h: No such file or directory
.
.
.
many more errors
I have included in my .bash_profile file the following:
export ABSOLUTE_PATH_TO_TALIB_HEADERS=/opt/local/var/macports/software/ta-lib/0.4.0_0/opt/local/include/ta-lib
export ABSOLUTE_PATH_TO_TALIB_LIBS=/opt/local/var/macports/software/ta-lib/0.4.0_0/opt/local/lib
And indeed the ta_abstract.h file is located where I'm saying in the ABSOLUTE_PATH variable assignment.
What gives?
UPDATE:
When all else fails, email correspondence with the gem author may help. Instead of export ABSOLUTE_PATH, he suggests passing the actual path in with the install. Along with explicitly passing in ARCHFLAGS="-arch x86_64", which works for Snow Leopard. The install still fails but now because it has issues with the talib.c file and certain functions therein.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
gem 作者通过电子邮件回答了这个问题的答案,但我想分享一下解决方案。
值得注意的是,这个 gem 也不兼容 Ruby 1.9.2。从生成的错误列表来看,它在 struct RObject 的定义(用字符串、数组等填充对象)方面存在一些问题,我追溯到 ruby.h 头文件。如果您想使用这个 gem,您可以安装 rvm,然后输入
From There,只需按照 gem 作者的指导以及上面列出的输入即可。
更新:gem 作者已使 talib_ruby 与 1.9.x 兼容,因此不再需要安装 1.8.7
The answer to this question was answered by the gem author via email, but I'd like to share the solution.
It is important to note that this gem is also not compatible with Ruby 1.9.2. From what the error list generated, it had some issues with the definition of struct RObject (fill in Object with String, Array, etc), which I traced to the ruby.h header file. If you'd like to use this gem, you can install rvm and then type
From there, simply follow the guidance from the gem author with the input listed above.
UPDATE: the gem author has made talib_ruby compatible with 1.9.x so there is no longer a need to install 1.8.7
观察
sudo echo $ABSOLUTE_PATH_TO_TALIB_HEADERS
echo ABSOLUTE_PATH_TO_TALIB_HEADERS
sudo
你是 root 吗?
将环境变量放在命令行上就可以了,或者将它们添加到 root 的环境中。
Observe
sudo echo $ABSOLUTE_PATH_TO_TALIB_HEADERS
echo ABSOLUTE_PATH_TO_TALIB_HEADERS
sudo
Are you root?
put the env vars on the command line and you should be good, alternatively add them to root's env.
只需添加brew安装的ta-lib的答案。
Just adding an answer for brew installed ta-lib.