How to specify header search path when using R CMD SHLIB to compile a C ++ file?

I am trying to compile a C ++ file that 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 shell using

g++ -I/usr/local/boost simple.cpp

then everything is all right. But I would like to create a shared library to use to speed up my R project. If I use

R CMD SHLIB test.cpp

then it reports that the header file was not found. Is there a way to specify a search path for R CMD? Sort of

R CMD SHLIB -I/usr/local/boost test.cpp
+5
source share
1 answer

PKG_CXXFLAGS - . 1.2. " Makevars" , 5.5 " " .

+8

All Articles