Link against MacPorts Ruby instead of system Ruby

Christopher Jones jonesc at hep.phy.cam.ac.uk
Sun Apr 27 02:15:12 PDT 2014


On 27 Apr 2014, at 4:05am, Kevin Walzer <kw at codebykevin.com> wrote:

> On 4/26/14, 2:03 PM, Christopher Jones wrote:
>> 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.
> 
> This did the trick:
> 
> 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/universal-darwin13/

Glad it filly worked.

However, as Ryan kindly pointed out, much better to use pkg-config than to hardcode the above paths. i.e. use

> gcc -Wall -v -o run run.c `pkg-config ruby-2.1 --cflags —libs`

where `pkg-config ruby-2.1 --cflags —libs` expands dynamically to

 > pkg-config ruby-2.1 --cflags —libs 

-I/opt/local/include/ruby-2.1.0/x86_64-darwin13 -I/opt/local/include/ruby-2.1.0 -L/opt/local/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -lruby.2.1.0 -lpthread -ldl -lobjc 

Chris

> Thanks.
> 
> -- 
> 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/20140427/c5bf6080/attachment.p7s>


More information about the macports-users mailing list