Skip to content

Rcpp on OSX?

5 messages · David Reiss, Brian Ripley, Simon Urbanek +1 more

#
The errors I get differ from yours (are your R and Xcode up to date?) but 
the problem is a fundamentally flawed Rcpp/src/Makefile. 
Here the lines I had to change (OS 10.5.5, R 2.8.0, Xcode 3.1.1):

PKGLIB          = Rcpp$(SHLIB_EXT)

$(PKGLIB):      $(PKGOBJ)
                 $(SHLIB_LINK) -o $(PKGLIB) $(PKGOBJ)

$(USERLIB):     $(USEROBJ)
                 $(DYLIB_LINK) -o $(USERLIB) $(USEROBJ) $(LIBR)
                 @cp Rcpp.h $(USERDIR)

But, I would not start from here, rather write a src/Makevars following 
the actual R documentation.  The package may compile on Debian Linux, but 
it compiles on none of my systems, not even the Linux ones.
On Thu, 20 Nov 2008, David Reiss wrote:

            

  
    
#
David,

you may want to tell the maintainer (hopefully CCed here ;)). That  
package is horribly non-portable (for no real reason) so it's not just  
a matter of setting some flags to get it to work. (Re the message you  
quoted - It's not really excluded, it simply doesn't work).

Just to get you started, *remove* src/Makefile and create the  
following src/Makevars:

all: $(SHLIB) userLibrary

USERLIB=libRcpp$(DYLIB_EXT)
USERDIR=../inst/lib

userLibrary: $(USERLIB)
	- at if test ! -e $(USERDIR)$(R_ARCH); then mkdir -p $(USERDIR)$ 
(R_ARCH); fi
	cp $(USERLIB) $(USERDIR)$(R_ARCH)
	cp Rcpp.h $(USERDIR)

$(USERLIB): Rcpp.o
	$(SHLIB_CXXLD) -o $(USERLIB) $^ $(SHLIB_CXXLDFLAGS) $(ALL_LIBS)

.PHONY: 	all clean userLibrary

clean:
		rm -f $(OBJECTS) $(SHLIB) $(USERLIB)


Cheers,
Simon
On Nov 20, 2008, at 16:57 , David Reiss wrote:

            
#
Simon,  David,
On 20 November 2008 at 18:17, Simon Urbanek wrote:
| David,
| 
| you may want to tell the maintainer (hopefully CCed here ;)). That  
| package is horribly non-portable (for no real reason) so it's not just  

The reason is that I need to work around restrictions in R about how and I
where I can build libraries.  And e.g. the complete lack of follow-up from R
Core about the suggested additions to the R CMD INSTALL functionality (cf
r-devel in the summer).

Rcpp builds and works for me under Linux and Windows -- the only platforms I
have access too -- and I use it daily.  I had asked a friend who uses OS X to
test this, but he hadn't gotten around to it.  So OS X is simply untested.

On Windows and Linux I now install one copy of Rcpp and have other package
compile and link against it.

| a matter of setting some flags to get it to work. (Re the message you  
| quoted - It's not really excluded, it simply doesn't work).
| 
| Just to get you started, *remove* src/Makefile and create the  
| following src/Makevars:
| 
| all: $(SHLIB) userLibrary
| 
| USERLIB=libRcpp$(DYLIB_EXT)
| USERDIR=../inst/lib
| 
| userLibrary: $(USERLIB)
| 	- at if test ! -e $(USERDIR)$(R_ARCH); then mkdir -p $(USERDIR)$ 
| (R_ARCH); fi
| 	cp $(USERLIB) $(USERDIR)$(R_ARCH)
| 	cp Rcpp.h $(USERDIR)

The platforms I work on don't need the $R_ARCH stuff which is why I didn't
add it.  If this is portable, we can surely talk about making it more
generic.  

If David is willing to test this, we can probably sort this out over a few
off-list emails. I'd be up for that.

| $(USERLIB): Rcpp.o
| 	$(SHLIB_CXXLD) -o $(USERLIB) $^ $(SHLIB_CXXLDFLAGS) $(ALL_LIBS)
| 
| .PHONY: 	all clean userLibrary
| 
| clean:
| 		rm -f $(OBJECTS) $(SHLIB) $(USERLIB)

That is overall a pretty small change.  So I don't see the need for the
belligerent tone above, especially given that I have no access to OS X.

Thanks, Dirk

 
| 
| Cheers,
| Simon
| 
|
| On Nov 20, 2008, at 16:57 , David Reiss wrote:
| 
| > Hi,
| > I am very eager to use Rcpp on my Mac. However, the package doesn't  
| > compile,
| > as reported at CRAN ("MacOS X binary: not available as excluded from  
| > build,
| > see excludes<https://svn.r-project.org/R-dev-web/trunk/QA/Simon/packages/excludes 
| > >.")
| > I thought I'd check if any R/OSX experts here have gotten it to  
| > work, or
| > have any ideas on how to compile it on OSX, before I tried  
| > contacting the
| > package maintainer. Here are the compilation errors I get when I try  
| > (on my
| > 2nd-gen Mac Pro running Tiger; similar results on a Leopard box).  
| > Thanks for
| > any assistance.
| >
| > % R CMD INSTALL Rcpp_0.6.0.tar.gz
| > * Installing *source* package 'Rcpp' ...
| > ** libs
| > ** arch - i386
| > g++ -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
| > -mmacosx-version-min=10.4
| > -I/Library/Frameworks/R.framework/Resources/include
| > -I/Library/Frameworks/R.framework/Resources/include/i386  -msse3    - 
| > fPIC
| > -I. `/Library/Frameworks/R.framework/Resources/bin/R CMD config -- 
| > cppflags`
| > -Wall -O2  -c Rcpp.cpp -o Rcpp.o
| > g++ -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
| > -mmacosx-version-min=10.4 -shared -o ../inst/lib/libRcpp.dylib Rcpp.o
| > i686-apple-darwin8-g++-4.0.1: unrecognized option '-shared'
| > /usr/bin/ld: Undefined symbols:
| > _main
| > _INTEGER
| > _LOGICAL
| > _REAL
| > _R_CHAR
| > _R_ClassSymbol
| > _R_DimSymbol
| > _R_LevelsSymbol
| > _R_NamesSymbol
| > _R_NilValue
| > _R_alloc
| > _Rf_allocMatrix
| > _Rf_allocVector
| > _Rf_eval
| > _Rf_getAttrib
| > _Rf_isFactor
| > _Rf_isInteger
| > _Rf_isLogical
| > _Rf_isMatrix
| > _Rf_isNewList
| > _Rf_isNumeric
| > _Rf_isReal
| > _Rf_isString
| > _Rf_isVector
| > _Rf_lang2
| > _Rf_length
| > _Rf_mkChar
| > _Rf_protect
| > _Rf_setAttrib
| > _Rf_unprotect
| > _SETCADR
| > _SET_STRING_ELT
| > _SET_VECTOR_ELT
| > _STRING_ELT
| > _VECTOR_ELT
| > collect2: ld returned 1 exit status
| > make: *** [../inst/lib/libRcpp.dylib] Error 1
| > ERROR: compilation failed for package 'Rcpp'
| > ** Removing '/Users/dreiss/.R/packages/Rcpp'
| >
| > 	[[alternative HTML version deleted]]
| >
| > _______________________________________________
| > R-SIG-Mac mailing list
| > R-SIG-Mac at stat.math.ethz.ch
| > https://stat.ethz.ch/mailman/listinfo/r-sig-mac
| >
| >
|
#
On Nov 20, 2008, at 6:39 PM, Dirk Eddelbuettel wrote:

            
See Brian's e-mail - it builds on very specific setups of some Linux  
systems only (Windows is a different story since you have a separate  
makefile for that and it's a closed system).
The R_ARCH part is just the icing on the cake - the main problems are  
hard-coding flags like "-shared", how to compile so's, wrong names for  
the package library etc. etc.
Using a Makefile is always a very last resort that one should take  
only if you are sure that you won't need anything from R (not true  
here) and you are really sure that you know what you're doing.
Small? Wow - it's a completely different approach...
Hm... I don't see any mention of 'altruistic' in the dictionary for  
'belligerent' so I hope it's just a typo ;).

Cheers,
S