[R-SIG-Mac] Cocoa gui with embedded R framework

Simon Urbanek simon.urbanek at r-project.org
Wed Mar 23 21:56:28 CET 2005


Kjell,

On Mar 23, 2005, at 3:33 PM, Kjell Konis wrote:

> The way I am imagining this working out is that the linked path and  
> R_HOME will both be set dynamically relative to the location of  
> R.app when it is launched.  The @executable_path token seems to do  
> the trick for the linked path.  R.app always finds libR.dylib in  
> the embedded framework even if the R_HOME variable is not set.   
> Tomorrow I will try to get Rcontroller to set R_HOME relative to  
> the location of R.app at launch.  Then (again the way I am  
> imagining things) everything should work unless you move R.app  
> while it is running - which hopefully the OS won't let you do.

In fact, it's as simple as this:

setenv("R_HOME", [[[NSBundle bundleWithIdentifier:@"org.r-project.R- 
framework"] resourcePath] UTF8String], 1);

Add the above anywhere before REngine is initialized. I hope it gives  
the absolute path even for private frameworks. Remember, however,  
that you need to fix DYLD_LIBRARY_PATH correspondingly, too. If I  
remember correctly that cannot be done inside the binary, so the  
above approach won't help you there. You may experiment with the  
Info.plist, though - let us know if you find an easy solution.

Cheers,
Simon



More information about the R-SIG-Mac mailing list