From simon.urbanek at r-project.org  Fri May 24 01:54:44 2013
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Thu, 23 May 2013 19:54:44 -0400
Subject: [Rd] Using a shared object without installing a library
	required by the object.
In-Reply-To: <CAGBzz=KXMjCFkHJyW4FhkWjqtqvRt-e1YoM=N-KwFmOfpDvt_w@mail.gmail.com>
References: <CAGBzz=KXMjCFkHJyW4FhkWjqtqvRt-e1YoM=N-KwFmOfpDvt_w@mail.gmail.com>
Message-ID: <216071C9-5257-4E30-BE6D-664A4CE984FA@r-project.org>

On May 23, 2013, at 4:18 PM, Xiao He <praguewatermelon at gmail.com> wrote:

> Dear all,
> 
> I have a C++ code. To create a shared object from this particular code, I
> had to install a Fortran library on my computer (Mac). The compiled code
> runs fine on my computer. However,  if I try to dyn.load() said shared
> object on a computer that does not have the Fortran library installed, the
> object won't load, and instead I get a message below:
> 
> usr/local/lib/libgfortran.2.dylib
> Referenced from: /Users/xh/Downloads/foo2.so
> 
> I wonder if there is any way to compile the original C++ code such that I
> can include the necessary components of the Fortran library without having
> to install the library.
> 

The Fortran run-time is included with R, so you only need to change the path -- e.g.

install_name_tool -change /usr/local/lib/libgfortran.2.dylib /Library/Frameworks/R.framework/Resources/lib/libgfortran.2.dylib /Users/xh/Downloads/foo2.so

You can make that permanent on your build machine by running

install_name_tool -id  /Library/Frameworks/R.framework/Resources/lib/libgfortran.2.dylib /usr/local/lib/libgfortran.2.dylib

If you do that, all code compiled against it subsequently will point to the version inside R instead.

Cheers,
Simon

FWIW: There is R-SIG-Mac for Mac-specific questions.


> 
> Thank you in advance.
> 
> Best,
> Xiao
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 



[Rd] Using a shared object without installing a library required by the object.
Simon Urbanek