I’m trying to compile a C++ file which uses the Boost library on Mac OSX. For example, see the following “simple.cpp”
#include <boost/random.hpp>
using namesapce boost::math;
int main(){
boost::mt19937 rng;
rng.seed(static_cast<boost::uint32_t> (std::time(0)));
return 0;
}
If I compile the file in the command shell with
g++ -I/usr/local/boost simple.cpp
then everything is fine. But I’d like to build a shared library so that I can use it to speed up my R project. If I use
R CMD SHLIB test.cpp
then it reports the header file can not be found. Is there a way to specify the search path for R CMD? Something like
R CMD SHLIB -I/usr/local/boost test.cpp
You want to set
PKG_CXXFLAGS— see the fine manual’s Section 1.2. “Using Makevars” as well asSection 5.5 “Creating shared objects” for details.