Link against MacPorts Ruby instead of system Ruby

Christopher Jones jonesc at hep.phy.cam.ac.uk
Sat Apr 26 11:03:45 PDT 2014


Hi,

You should try looking around in the includes directory a bit ….

ruby/config.h exists in

/opt/local/include/ruby-2.1.0/x86_64-darwin13

so it looks like you need to add

-I/opt/local/include/ruby-2.1.0/x86_64-darwin13

to your compilation command. No idea if this is normal ruby behaviour, as I said I am not a user or ruby.

Chris

On 26 Apr 2014, at 7:00pm, Christopher Jones <jonesc at hep.phy.cam.ac.uk> wrote:

> Hi,
> 
> ( Why do you have -I/opt/local/include/ruby-2.1.0/ twice ? )
> 
> Looking at
> 
> MacBookPro /opt/local/include/ruby-2.1.0 > ls
> ruby		ruby.h		x86_64-darwin13
> 
> I see there is a ruby.h there. This file sets various things then includes <ruby/ruby.h>
> 
> I not a user of ruby, so I am guessing here, but what happens if you include
> 
> #include <ruby.h>
> 
> instead, to pick up /opt/local/include/ruby-2.1.0/ruby.h
> 
> ?
> 
> Chris
> 
> 
> 
> 
> On 26 Apr 2014, at 5:59pm, Kevin Walzer <kw at codebykevin.com> wrote:
> 
>> 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
> 
> _______________________________________________
> macports-users mailing list
> macports-users at lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macports-users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2030 bytes
Desc: not available
URL: <https://lists.macosforge.org/pipermail/macports-users/attachments/20140426/514ab558/attachment.p7s>


More information about the macports-users mailing list