Hello, I am trying to link the Rcpp package with "deepstate" which is a static library helps us fuzz test the functions in the Rcpp package.
TestHarness.cpp file creates a test harness using TEST(). Test harness file in RcppDeepState/src/TestHarness.cpp has code to test the function in rcpp_interface.cpp I tried compiling the code TestHarness.cpp and used -ldeepstate to a link it to deepstate using : *clang++ -o TestRcppharness TestRcppharness.cpp -I"/usr/share/R/include" -I"/usr/lib/R/site-library/Rcpp/include" -ldeepstate* But this does nothing and keeps throwing *static assertion failed: cannot convert type to SEXP error.* Below code: DeepState_Test class generates random numeric, Integer vectors and later passing those inputs to the rcpp_binseg_normal(random numeric vector, random Integer vector) TestHarness.cpp ---------------------- #include <deepstate/DeepState.hpp> #include "rcpp_interface.h" #include <Rcpp.h> using namespace Rcpp; using namespace deepstate; class DeepState_Test{ public: Rcpp::NumericVector NumericRand_vec; Rcpp::NumericVector values; Rcpp::IntegerVector IntegerRand_vec; Rcpp::NumericVector Missing_values(){ values = Rcpp::NumericVector::create(NA_REAL,R_NaN,R_PosInf,R_NegInf); return values; } Rcpp::NumericVector RcppDeepState_NumericVector() { int num_vector_size = DeepState_RandInt(); NumericRand_vec = new NumericVector[num_vector_size]; for(int i=0; i< num_vector_size; i++){ OneOf( [&] { NumericRand_vec[i] = DeepState_Double(); }, [&] { NumericRand_vec[i] = DeepState_DoubleInRange(0,DeepState_Double()); }); } return (NumericRand_vec); } Rcpp::IntegerVector RcppDeepState_IntegerVector(){ int int_vector_size = DeepState_RandInt(); IntegerRand_vec = new IntegerVector[int_vector_size]; for(int i=0; i< int_vector_size; i++){ OneOf( [&] { IntegerRand_vec[i] = DeepState_Int(); }, [&] { IntegerRand_vec[i] = DeepState_IntInRange(0,DeepState_RandInt()); }); } return IntegerRand_vec; } }; TEST(Random_Set, Ranges) { DeepState_Test *deeptest= new DeepState_Test(); Rcpp::NumericVector data_vec = deeptest->RcppDeepState_NumericVector(); Rcpp::IntegerVector max_segments = deeptest->RcppDeepState_IntegerVector(); //call to function in rcpp_interface rcpp_binseg_normal(data_vec,max_segments); } function in rcpp_interface.cpp : #include <Rcpp.h> #include <R.h> #include "binseg_normal.h" #include "binseg_normal_cost.h" // [[Rcpp::export]] Rcpp::List rcpp_binseg_normal (const Rcpp::NumericVector data_vec, const Rcpp::IntegerVector max_segments) { int kmax = max_segments[0]; Rcpp::IntegerVector end(kmax); Rcpp::NumericVector loss(kmax); Rcpp::NumericVector before_mean(kmax); Rcpp::NumericVector after_mean(kmax); Rcpp::IntegerVector before_size(kmax); Rcpp::IntegerVector after_size(kmax); Rcpp::IntegerVector invalidates_index(kmax); Rcpp::IntegerVector invalidates_after(kmax); int status = binseg_normal (&data_vec[0], data_vec.size(), kmax, //inputs above, outputs below. &end[0], &loss[0], &before_mean[0], &after_mean[0], &before_size[0], &after_size[0], &invalidates_index[0], &invalidates_after[0]); if(status == ERROR_NO_DATA){ Rcpp::stop("no data"); } if(status == ERROR_NO_SEGMENTS){ Rcpp::stop("no segments"); } if(status == ERROR_TOO_MANY_SEGMENTS){ Rcpp::stop("too many segments"); } return Rcpp::List::create (Rcpp::Named("loss", loss), Rcpp::Named("end", end), Rcpp::Named("before.mean", before_mean), Rcpp::Named("after.mean", after_mean), Rcpp::Named("before.size", before_size), Rcpp::Named("after.size", after_size), Rcpp::Named("invalidates.index", invalidates_index), Rcpp::Named("invalidates.after", invalidates_after) ) ; } *How can I compile Rcpp package or src/*.cpp files to get an executable and linking a static library to it while it is being compiled.* *How can I generate an executable Rcpp package using the command line(command) by linking deep state library instead of generating a RcppDeepState.so(not an executable) file dynamically using (R CMD INSTALL .)* Thanks, Akhila Chowdary
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel