[Rcpp-devel] 'Symbol not found' error
Noam Ross
noam.ross at gmail.com
Thu Oct 3 19:19:44 CEST 2013
I am getting the following error when attempting to load a package built
using Rcpp with Rstudio's build tools:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object
'/home/noamross/R/x86_64-pc-linux-gnu-library/3.0/sodi/libs/sodi.so':
/home/noamross/R/x86_64-pc-linux-gnu-library/3.0/sodi/libs/sodi.so:
undefined symbol:
_Z11print_statedR9statelistRSt14basic_ofstreamIcSt11char_traitsIcEERN4arma3MatIdEE
This appears to refer to my print_state function:
#include <fstream>
#include <RcppArmadillo.h>
#include "data_structures.h"
void print_state(double outtime, statelist &state, std::ofstream
outfile, arma::mat &printmatrix) {
printmatrix.col(0).fill(outtime);
printmatrix.col(1) = arma::conv_to<arma::vec>::from(state.ID);
printmatrix.col(2) = state.X;
printmatrix.col(3) = state.Y;
printmatrix.col(4) = arma::conv_to<arma::vec>::from(state.S);
printmatrix.col(5) = arma::conv_to<arma::vec>::from(state.I);
arma::mat p = printmatrix(arma::span(0, state.treeindex), arma::span(0, 5));
p.save(outfile, arma::csv_ascii);
}
statelist is custom struct with default constructors/deconstructors (in
data_structures.h). print_state is also declared in print_state.h:
extern void print_state(double outtime, statelist &state,
std::ofstream &outfile, arma::mat &printmatrix);
print_state is only called once in my code, in a loop, in a function in a
different file (run_sodi in run_sodi.cpp), which has #include
"print_state.h":
if (state.time >= *next_record) {
print_state(*next_record, state, outfile, printmatrix);
++next_record;
}
Here next_record is defined previously in run_sodi as NumericVector::iterator
next_record = times.begin();. If I comment out the above print_state call
and re-compile, the package will load.
I've tried this compiling using both g++ and clang++ on linux and OSX
machines, respectively, with the same results.
All this code found at https://github.com/noamross/sodi/tree/Rcpp-Dev/src
Any ideas where to hunt this down? Thanks!
Noam Ross
Graduate Group in Ecology
Department of Environmental Science and Policy
University of California at Davis
+1.646.244.0484
http://www.noamross.net/
twitter: @noamross
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131003/0b0a3f6e/attachment-0001.html>
More information about the Rcpp-devel
mailing list