I just finished building a C++ extension using Rcpp on Mac OS X and have a couple tips for anyone trying to do the same.
I used RcppTemplate as a starting point. When developing and testing, it was easier to compile the extension by hand and use dyn.load() as opposed to using the R packaging mechanism to rebuild the entire package every time. In compiling RcppTemplate I ran into the following difficulties on Mac OS X 10.5: - ./configure is broken due to some missing environment vars. Use "R_ARCH="/`arch`" R_SHARE_DIR=$R_HOME/share ./configure" instead. - Marking a function RcppExport will cause the compile to fail because __declspec(dllexport) is Windows-specific and not recognized by the Apple compiler. Change the lines in Rcpp.hpp from #ifdef BUILDING_DLL #define RcppExport extern "C" __declspec(dllexport) #else #define RcppExport extern "C" #endif to #if BUILDING_DLL && WIN32 #define RcppExport extern "C" __declspec(dllexport) #else #define RcppExport extern "C" #endif or if you don't care about cross-platform just write #define RcppExport extern "C" - Loading your compiled DLL using dyn.load() will complain about not being able to find libRcpp. I think this is due to an improper path-name being embedded in the library when it is compiled on your machine. $ otool -L /Library/Frameworks/R.framework/Resources/library/Rcpp/lib/ i386/libRcpp.dylib /Library/Frameworks/R.framework/Resources/library/Rcpp/lib/i386/ libRcpp.dylib: /Builds/Rdev-web/QA/Simon/packages/tiger-universal/Rlib/2.8/Rcpp/lib/ i386/libRcpp.dylib (compatibility version 0.0.0, current version 0.0.0) For now you can fix this in your .dll using install_name_tool -- see http://qin.laya.com/tech_coding_help/dylib_linking.html for a good description of what needs to be done. A better solution would be for the package maintainer to change the build process so this gets generated correctly. After I had the extension written and functioning properly, I used package.skeleton to generate a tree, and then copied all of the source files in the /src directory (including Rcpp.cpp and Rcpp.hpp) and generated the proper firstlib.R file to load in my functions. After this things went smoothly--'R CMD build' correctly compiled all of the source files into a shared object file and I was able to build and install the package with no further modifications. It took me a little while to figure all of this out, so I figured I'd post it to hopefully save someone else the time. Jonathan [[alternative HTML version deleted]] _______________________________________________ R-SIG-Mac mailing list R-SIG-Mac@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-mac