[Rcpp-devel] 'Symbol not found' error

Steve Jaffe sjaffe at riskspan.com
Thu Oct 3 23:17:47 CEST 2013

If your code really is as written: 

void print_state(    double outtime, statelist &state, 
				std::ofstream outfile, 
				arma::mat &printmatrix)

I'd be suspicious of std::ofstream outfile passed by value not reference. 

The copy constructor is private so I don't see how this would compile. 

Which would explain why the library is missing. 

But if that were the case you should have compiler errors; could they have been overlooked?



Message: 7
Date: Thu, 3 Oct 2013 10:19:44 -0700
From: Noam Ross <noam.ross at gmail.com>
To: rcpp-devel at lists.r-forge.r-project.org
Subject: [Rcpp-devel] 'Symbol not found' error
	<CA+Ygi5nHSdBYmXB9eZ_E58QAOYDbY8twm_otGM4r1DRWh619kw at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

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
undefined symbol:

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(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

if (state.time >= *next_record) {

  print_state(*next_record, state, outfile, printmatrix);

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
twitter: @noamross
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131003/0b0a3f6e/attachment.html>


Rcpp-devel mailing list
Rcpp-devel at lists.r-forge.r-project.org

End of Rcpp-devel Digest, Vol 48, Issue 8

More information about the Rcpp-devel mailing list