Link against MacPorts Ruby instead of system Ruby

Kevin Walzer kw at codebykevin.com
Sat Apr 26 09:59:10 PDT 2014


On 4/26/14, 12:27 PM, Chris Jones wrote:
> Do you not include any ruby headers in your code ? If you do, you should make sure to pick those matching the library you are using. It might well work without, but that will be just by pure chance..

Just this:

#include <ruby/ruby.h>

If I use the "-I" flag, like so:

gcc -Wall -v -o run run.c -L/opt/local/lib -lruby.2.1 
-I/opt/local/include/ruby-2.1.0/ -I/opt/local/include/ruby-2.1.0/

then it fails to compile, with this error:

#include <...> search starts here:
  /opt/local/include/ruby-2.1.0
 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include
 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include
 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks 
(framework directory)
End of search list.
In file included from run.c:1:
/opt/local/include/ruby-2.1.0/ruby/ruby.h:24:10: fatal error: 
'ruby/config.h'
       file not found
#include "ruby/config.h"
          ^

Ruby seems to have a convoluted batch of headers; multiple versions of 
"ruby.h" are located in the tree for reasons unknown to me. I've seen 
this error before when trying to compile against MacPorts Ruby and 
trying to guess at the include path.

Any suggestions, especially when the other invocation works as expected?

--Kevin

-- 
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com


More information about the macports-users mailing list