[Rcpp-devel] undefined reference
Kevin Kunzmann
kevinkunzmann at gmx.net
Fri Sep 26 23:10:21 CEST 2014
Hi Guys,
I am getting this strange error:
g++ -m64 -shared -s -static-libgcc -o cme.dll tmp.def RcppExports.o cme.o misc.o pb.o C:/Users/Kevin/R/win-library/3.1/RcppMLPACK/lib/x64/libRcppMLPACK.a -LC:/R/R-31~1.1/bin/x64 -lRlapack -LC:/R/R-31~1.1/bin/x64 -lRblas -lgfortran -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/R/R-31~1.1/bin/x64 -lR
RcppExports.o:RcppExports.cpp:(.text+0x2f83): undefined reference to `condMVNormParams(arma::Col<double>, arma::Mat<double>, arma::Col<unsigned int>, arma::Col<double>)'
collect2: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'cme'
* removing 'C:/Users/Kevin/R/win-library/3.1/cme'
Exited with status 1.
after trying to build my project in Rstudio on Windows 8.1 , here is the
function
// [[Rcpp::export]]
Rcpp::List condMVNormParams(arma::vec mu,
arma::mat Sigma,
arma::uvec inds,
arma::vec values)
{
// tested, 10x faster than R implementation!
// convenience: use R index conventions
inds = inds - arma::ones<arma::uvec>(inds.n_elem);
// declare return values
int d = mu.n_elem;
int nLeft = d - inds.n_elem;
arma::vec muCond = arma::vec(nLeft);
arma::mat SigmaCond = arma::mat(nLeft, nLeft);
// find an ordering, that orders unknown first, known later
arma::uvec perm = arma::uvec(d);
int indsFound = 0;
int indsNotFound = 0;
for(int i = 0; i < d; i++)
{
if(any(inds == i))
{
// that is an index on which we condition -> sort to
end of vector
perm(nLeft + indsFound) = i;
indsFound += 1;
} else {
// index of coordinate we do not condition on!
perm(indsNotFound) = i;
indsNotFound += 1;
}
}
// sort mu and Sigma by perm
mu = mu(perm);
Sigma = Sigma(perm, perm);
// compute conditional matrices
arma::mat S11 = Sigma.submat(0, 0, nLeft - 1, nLeft - 1);
arma::mat S12 = Sigma.submat(0, nLeft, nLeft - 1, d - 1);
arma::mat S21 = Sigma.submat(nLeft, 0, d - 1, nLeft - 1);
arma::mat S22 = Sigma.submat(nLeft, nLeft, d - 1, d - 1);
arma::vec mu1 = mu.subvec(0, nLeft - 1);
arma::vec mu2 = mu.subvec(nLeft, d - 1);
muCond = mu1 + S12*inv(S22)*(values - mu2);
SigmaCond = S11 - S12*inv(S22)*S21;
return Rcpp::List::create(Rcpp::Named("mu") = muCond,
Rcpp::Named("Sigma") = SigmaCond);
}
I did not touch any of the automatically generated files, here is
RcppExports.cpp
// This file was generated by Rcpp::compileAttributes
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <RcppArmadillo.h>
#include <RcppMLPACK.h>
#include <Rcpp.h>
using namespace Rcpp;
// stageMean
double stageMean(arma::mat data, int stage, int treatment, int marker);
RcppExport SEXP cme_stageMean(SEXP dataSEXP, SEXP stageSEXP, SEXP
treatmentSEXP, SEXP markerSEXP) {
BEGIN_RCPP
SEXP __sexp_result;
{
Rcpp::RNGScope __rngScope;
Rcpp::traits::input_parameter< arma::mat >::type
data(dataSEXP );
Rcpp::traits::input_parameter< int >::type stage(stageSEXP );
Rcpp::traits::input_parameter< int >::type
treatment(treatmentSEXP );
Rcpp::traits::input_parameter< int >::type marker(markerSEXP );
double __result = stageMean(data, stage, treatment, marker);
PROTECT(__sexp_result = Rcpp::wrap(__result));
}
UNPROTECT(1);
return __sexp_result;
END_RCPP
}
// condMVNormParams
Rcpp::List condMVNormParams(arma::vec mu, arma::mat Sigma,
arma::uvec inds, arma::vec values);
RcppExport SEXP cme_condMVNormParams(SEXP muSEXP, SEXP SigmaSEXP,
SEXP indsSEXP, SEXP valuesSEXP) {
BEGIN_RCPP
SEXP __sexp_result;
{
Rcpp::RNGScope __rngScope;
Rcpp::traits::input_parameter< arma::vec >::type mu(muSEXP );
Rcpp::traits::input_parameter< arma::mat >::type
Sigma(SigmaSEXP );
Rcpp::traits::input_parameter< arma::uvec >::type
inds(indsSEXP );
Rcpp::traits::input_parameter< arma::vec >::type
values(valuesSEXP );
Rcpp::List __result = condMVNormParams(mu, Sigma, inds,
values);
PROTECT(__sexp_result = Rcpp::wrap(__result));
}
UNPROTECT(1);
return __sexp_result;
END_RCPP
}
I was able to compile the same package on a different machine (32bit)
but did a clean rebuild. Any Idea what might have gone wrong?
Best,
Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140926/962cb492/attachment-0001.html>
More information about the Rcpp-devel
mailing list