[Phylobase-devl] Rcpp and OS X compiliation

Dirk Eddelbuettel edd at debian.org
Sun Jan 17 18:45:13 CET 2010


All,

Here is a bit more about OS X, Rcpp and dyn loading. I was scratching my head
as 'something seemed to be missing'.  A comment in the sources made me
remember.  In the R file defining CxxFlags() and LdFlags(), I say

   ## Provide linker flags -- i.e. -L/path/to/libRcpp -- as well as an
   ## optional rpath call needed to tell the Linux dynamic linker about the
   ## location.  This is not needed on OS X where we encode this as library
   ## built time (see src/Makevars) or Windows where we use a static library

so the 'rpath' business is used only Linux (where it works, but can break if
you move or remove the dynamic library; static linking would be failsafe).

On OS X we do this at package build time (ie when Rcpp is built):
 
  $(USERLIB): 	$(USEROBJ)
		$(SHLIB_CXXLD) -o $(USERLIB) $^ $(SHLIB_CXXLDFLAGS) $(ALL_LIBS)
		@if test -e "/usr/bin/install_name_tool"; then \
                      /usr/bin/install_name_tool \
                         -id $(R_PACKAGE_DIR)/lib$(R_ARCH)/$(USERLIB) \
                         $(USERLIB); \
                fi

i.e. right after the shared library is build using SHLIB_CXXLD we test for a
tool /usr/bin/install_name_tool --- which apparently only OS X guys have ---
and it to encode the directory location $(R_PACKAGE_DIR)/lib$(R_ARCH)/$(USERLIB) 
in the share libary $(USERLIB) we just built.

And I just checked -- $(R_PACKAGE_DIR) points to the correct location for me.

Does this reasonable for OS X?   Someone with a minute to spare could maybe
remove the leading '@' from that line in src/Makevars.in so that we see how
this gets executed.

Dirk

-- 
Three out of two people have difficulties with fractions.


More information about the Phylobase-devl mailing list