Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Kevin Walzer
On Mavericks, I am developing a tool that uses an embedded Ruby interpreter and am trying to link it against my MacPorts installation of Ruby 2.1. However, while it successfully builds and runs with the following command: gcc -Wall -v -o test test.c -lruby it is linked against the system

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Christopher Jones
Hi, You need to use the -L option to tell the linker to look in your MacPorts installation. Also, if you want a particular ruby version, it would be better I think to explicitly link against that, rather than relying on what ‘libruby’ point to so (if your installation is in the default

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Christopher Jones
p.s. You probably also should use the -I option, to tell gcc to take the ruby includes from /opt/local/include/ruby-2.1.0/ as well, otherwise it will pick up the system ones, and thus there will be a miss match. On 26 Apr 2014, at 3:16pm, Christopher Jones jon...@hep.phy.cam.ac.uk wrote:

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Kevin Walzer
On 4/26/14, 10:16 AM, Christopher Jones wrote: -L/opt/local/lib -lruby.2.1 This worked great, thank you! -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com ___ macports-users mailing list

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Kevin Walzer
On 4/26/14, 10:21 AM, Christopher Jones wrote: p.s. You probably also should use the -I option, to tell gcc to take the ruby includes from /opt/local/include/ruby-2.1.0/ as well, otherwise it will pick up the system ones, and thus there will be a miss match. ...and this proved unnecessary.

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Chris Jones
Hi, On 26 Apr 2014, at 04:38 pm, Kevin Walzer k...@codebykevin.com wrote: On 4/26/14, 10:21 AM, Christopher Jones wrote: p.s. You probably also should use the -I option, to tell gcc to take the ruby includes from /opt/local/include/ruby-2.1.0/ as well, otherwise it will pick up the

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Kevin Walzer
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

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Brandon Allbery
On Sat, Apr 26, 2014 at 12:59 PM, Kevin Walzer k...@codebykevin.com wrote: Any suggestions, especially when the other invocation works as expected? It may link successfully but lead to obscure core dumps at runtime, if you're mixing the system ruby headers with a different ruby installation's

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Kevin Walzer
On 4/26/14, 1:38 PM, Brandon Allbery wrote: It may link successfully but lead to obscure core dumps at runtime, if you're mixing the system ruby headers with a different ruby installation's libraries. I understand that, but I am still not clear on how to pick up the MacPorts headers

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Kevin Walzer
On 4/26/14, 1:38 PM, Brandon Allbery wrote: It may link successfully but lead to obscure core dumps at runtime, if you're mixing the system ruby headers with a different ruby installation's libraries. I understand that, but I am still not clear on how to pick up the MacPorts headers

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Christopher Jones
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,

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Kevin Walzer
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.

Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Ryan Schmidt
On Apr 26, 2014, at 13:03, 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