Re: Link against MacPorts Ruby instead of system Ruby

2014-04-27 Thread Christopher Jones

On 27 Apr 2014, at 4:05am, Kevin Walzer  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@lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macports-users



smime.p7s
Description: S/MIME cryptographic signature
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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 compilation command. No idea if this is normal ruby behaviour, as I 
> said I am not a user or ruby.

You’ll want to let pkg-config find those values for you. On my system, I get:


$ pkg-config ruby-2.1 --cflags
-I/opt/local/include/ruby-2.1.0/universal-darwin13 
-I/opt/local/include/ruby-2.1.0 
$ pkg-config ruby-2.1 --libs
-L/opt/local/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress 
-lruby.2.1.0 -lpthread -ldl -lobjc 
$ 

___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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. 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/


Thanks.

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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, as I 
said I am not a user or ruby.

Chris

On 26 Apr 2014, at 7:00pm, Christopher Jones  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 
> 
> 
> I not a user of ruby, so I am guessing here, but what happens if you include
> 
> #include 
> 
> instead, to pick up /opt/local/include/ruby-2.1.0/ruby.h
> 
> ?
> 
> Chris
> 
> 
> 
> 
> On 26 Apr 2014, at 5:59pm, Kevin Walzer  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 
>> 
>> 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@lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macports-users



smime.p7s
Description: S/MIME cryptographic signature
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


Re: Link against MacPorts Ruby instead of system Ruby

2014-04-26 Thread Christopher Jones
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
rubyruby.h  x86_64-darwin13

I see there is a ruby.h there. This file sets various things then includes 


I not a user of ruby, so I am guessing here, but what happens if you include

#include 

instead, to pick up /opt/local/include/ruby-2.1.0/ruby.h

?

Chris




On 26 Apr 2014, at 5:59pm, Kevin Walzer  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 
> 
> 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



smime.p7s
Description: S/MIME cryptographic signature
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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 completely. The invocation Chris provided does not build.


--Kevin

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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 completely. The invocation Chris provided does not build.


--Kevin

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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  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
libraries.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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 

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@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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  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 system ones, and thus there will be a miss match.
> 
> ...and this proved unnecessary. So easy!

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..

> 
> -- 
> Kevin Walzer
> Code by Kevin/Mobile Code by Kevin
> http://www.codebykevin.com
> http://www.wtmobilesoftware.com
> ___
> macports-users mailing list
> macports-users@lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macports-users
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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. So easy!

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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  wrote:

> 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 prefix) use
> 
> -L/opt/local/lib -lruby.2.1
> 
> Chris
> 
> On 26 Apr 2014, at 2:55pm, Kevin Walzer  wrote:
> 
>> 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 Ruby, 2.0. (Apple has apparently replaced 
>> MacRuby with standard Ruby in Mavericks.)
>> 
>> Can anyone suggest the correct command-line invocation to point my tool at 
>> MacPorts Ruby instead?
>> 
>> --Kevin
>> -- 
>> Kevin Walzer
>> Code by Kevin/Mobile Code by Kevin
>> http://www.codebykevin.com
>> http://www.wtmobilesoftware.com
>> ___
>> macports-users mailing list
>> macports-users@lists.macosforge.org
>> https://lists.macosforge.org/mailman/listinfo/macports-users
> 
> ___
> macports-users mailing list
> macports-users@lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macports-users



smime.p7s
Description: S/MIME cryptographic signature
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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 prefix) use

-L/opt/local/lib -lruby.2.1

Chris

On 26 Apr 2014, at 2:55pm, Kevin Walzer  wrote:

> 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 Ruby, 2.0. (Apple has apparently replaced 
> MacRuby with standard Ruby in Mavericks.)
> 
> Can anyone suggest the correct command-line invocation to point my tool at 
> MacPorts Ruby instead?
> 
> --Kevin
> -- 
> Kevin Walzer
> Code by Kevin/Mobile Code by Kevin
> http://www.codebykevin.com
> http://www.wtmobilesoftware.com
> ___
> macports-users mailing list
> macports-users@lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macports-users



smime.p7s
Description: S/MIME cryptographic signature
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


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 Ruby, 2.0. (Apple has apparently 
replaced MacRuby with standard Ruby in Mavericks.)


Can anyone suggest the correct command-line invocation to point my tool 
at MacPorts Ruby instead?


--Kevin
--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users