[R] Rmath: R libraries from C on Mac OS X

Dirk Eddelbuettel edd at debian.org
Mon Dec 18 06:20:43 CET 2006


On 17 December 2006 at 23:19, Murali Haran wrote:
| I have been having trouble using R's standalone random number generators 
| from C on my Mac OS X 10.4.8 system.
| 
| I try to compile my C program in the following way:
| gcc -Wall -o helloMac helloMac.c -lm -lRmath
| I get the following error:
| /usr/bin/ld: can't locate file for: -lRmath
| 
| I am unable to locate Rmath on my machine. The problem appears to be 
| that no libRmath.a was built on my Mac OS X installation. 
| 
| Any pointers (perhaps to a step by step guide for a _beginner_ on how to 
| install this and then how to compile the C code) would be most 
| appreciated.For completeness, here is my C code (adapted from code that 
| works fine on Linux):

As you indicate yourself, the issue is presumably that there is no libRmath.
So you need to build one.  For the Debian/Ubuntu packages, we do the
following:

        # make standalone math lib
	(cd src/nmath/standalone;				\
		$(MAKE)	CFLAGS="$(cflags) -D_REENTRANT"		\
			CXXFLAGS="$(cxxflags) -D_REENTRANT"	\
			FFLAGS="$(fcflags) -D_REENTRANT"	\
			CC=${compiler}				\
			CXX=${cxxcompiler}			\
			${fortrancompiler}			\
			libRmath_la_LDFLAGS=-Wl,-soname,libRmath.so.$(somaj) \
			)

I would expect that you need to do a similar

	$ cd src/nmath/standalone && make

along with whichever flags you may need.  Details can surely be found in the
'R Admin' manual you may want to consult for this.

Hth, Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison



More information about the R-help mailing list