Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

ruby - gem install cannot find a header file

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The answer to this question was answered by the gem author via email, but I'd like to share the solution.

sudo env ARCHFLAGS="-arch x86_64" gem install talib_ruby -- --with-talib-include=/opt/local/var/macports/software/ta-lib/0.4.0_0/opt/local/include/ta-lib  --with-talib-lib=/opt/local/var/macports/software/ta-lib/0.4.0_0/opt/local/lib

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

rvm install ruby-1.8.7 --with-readline-dir=/opt/local

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...