Z
Z
Zaur2011-05-24 12:46:02
ruby
Zaur, 2011-05-24 12:46:02

Determining the paths to the directories of the ruby.h header file?

There is a task to determine the path to the header file ruby.h in a universal way, for subsequent compilation of the C script. For
example, for glib it is done like this:
pkg-config --cflags --libs glib-2.0

-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lglib-2.0

The pkg-config utility does not see ruby
​​What other ways are there, apart from "find and register by hand"?
Examples of what should happen:
-I/usr/lib64/ruby/1.8/x86_64-linux/ -lruby18
-I/opt/local/lib/ruby/1.8/i686-darwin10/ -lruby

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zaur, 2011-05-24
@zaurio

There is an option to do this through Ruby itself, but how usable is it?
ruby -rrbconfig -e 'puts Config::CONFIG["archdir"]'
And the question remains with the path to the interetator,
for example, if -lruby does not work, but -lruby18 works
$ ls -al /usr/bin/ | grep ruby
lrwxrwxrwx 1 root root 6 Mar 15 12:11 ruby -> ruby18
-rwxr-xr-x 1 root root 5984 Mar 15 12:11 ruby18

Z
Zaur, 2011-05-24
@zaurio

Crutch Is there anything smarter?
$ ruby -rrbconfig -e 'puts " -I" + Config::CONFIG["archdir"]'
-I/usr/lib64/ruby/1.8/x86_64-linux
$ ruby -rrbconfig -e 'puts " -L" + Config::CONFIG["libdir"] + " -l"+Config::CONFIG["RUBY_SO_NAME"]'
-L/usr/lib64 -lruby18

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question