为md :: exception'

时间:2016-05-27 13:38:43

标签: mingw rcpp

我正在尝试使用Rcpp

编译以下代码
#include <Rcpp.h>
#include <boost/thread.hpp>
using namespace Rcpp;

// parallelization test
void workerFunc()
{

  boost::posix_time::seconds workTime(3);
  std::cout << "Worker: Running" << '\n';
  //boost::this_thread::sleep(workTime);
  double k=1;
  for (int i = 1; i<100000000; ++i)
    k = k*sqrt(i);
  std::cout<< "Worker: Finished" << '\n';
}

// [[Rcpp::export]]  
void parallelTests() {
  // creates threads and joins them
  std::vector<boost::thread *> z;

  for (int i = 0; i < 15; ++i)
    z.push_back(new boost::thread(workerFunc));

  for (int i = 0; i < 15; ++i)
  {
    z[i]->join();
    delete z[i];
  }
}

收到以下错误

g++ -m64 -shared -s -static-libgcc -o sourceCpp_5.dll tmp.def CppThreadTest.o -L C:/mingw/MinGW/lib -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LC:/PROGRA~1/R/R-32~1.4/bin/x64 -lR
C:/mingw/MinGW/lib/libstdc++.a(stdexcept.o):stdexcept.cc:(.rdata$_ZTISt9exception[_ZTISt9exception]+0x0): multiple definition of `typeinfo for std::exception'
CppThreadTest.o:CppThreadTest.cpp:(.data$_ZTISt9exception[_ZTISt9exception]+0x0): first defined here
C:/mingw/MinGW/lib/libstdc++.a(stdexcept.o):stdexcept.cc:(.rdata$_ZTISt13runtime_error[_ZTISt13runtime_error]+0x0): multiple definition of `typeinfo for std::runtime_error'
CppThreadTest.o:CppThreadTest.cpp:(.data$_ZTISt13runtime_error[_ZTISt13runtime_error]+0x0): first defined here
C:/mingw/MinGW/lib/libstdc++.a(bad_alloc.o):bad_alloc.cc:(.rdata$_ZTISt9bad_alloc[_ZTISt9bad_alloc]+0x0): multiple definition of `typeinfo for std::bad_alloc'
CppThreadTest.o:CppThreadTest.cpp:(.data$_ZTISt9bad_alloc[_ZTISt9bad_alloc]+0x0): first defined here
C:/mingw/MinGW/lib/libstdc++.a(eh_exception.o):eh_exception.cc:(.rdata$_ZTISt13bad_exception[_ZTISt13bad_exception]+0x0): multiple definition of `typeinfo for std::bad_exception'

我的增强版安装随后来自以下发行版MINGW Distro

我在R中设置路径,然后编译

Sys.setenv("PKG_CXXFLAGS"="-I C:/mingw/MinGW/include")
Sys.setenv("PKG_LIBS"="-L C:/mingw/MinGW/lib")
Rcpp::sourceCpp('C:/temp/kvasvn/kva/CppThreadTest.cpp', verbose=TRUE)

你知道造成这种情况的原因吗?

编辑1:

好的第一个错误是由包含其他版本libstdc的C:/ mingw / MinGW / lib目录引起的。我刚刚将libboost_thread.a复制到C:/ mingw / MinGW / myFolder并包含了。现在有其他错误

g++ -m64 -shared -s -static-libgcc -o sourceCpp_11.dll tmp.def CppThreadTest.o -L C:/mingw/MinGW/myFolder -lboost_thread -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LC:/PROGRA~1/R/R-32~1.4/bin/x64 -lR
C:/mingw/MinGW/myFolder/libboost_thread.a(thread.o):thread.cpp:(.rdata$_ZTVN5boost6system12system_errorE[_ZTVN5boost6system12system_errorE]+0x0): multiple definition of `vtable for boost::system::system_error'
CppThreadTest.o:CppThreadTest.cpp:(.data$_ZTVN5boost6system12system_errorE[_ZTVN5boost6system12system_errorE]+0x0): first defined here
C:/mingw/MinGW/myFolder/libboost_thread.a(thread.o):thread.cpp:(.rdata$_ZTVN5boost16exception_detail10clone_baseE[_ZTVN5boost16exception_detail10clone_baseE]+0x0): multiple definition of `vtable for boost::exception_detail::clone_base'
CppThreadTest.o:CppThreadTest.cpp:(.data$_ZTVN5boost16exception_detail10clone_baseE[_ZTVN5boost16exception_detail10clone_baseE]+0x0): first defined here
C:/mingw/MinGW/myFolder/libboost_thread.a(thread.o):thread.cpp:(.rdata$_ZTVN5boost9exceptionE[_ZTVN5boost9exceptionE]+0x0): multiple definition of `vtable for boost::exception'

boost :: system :: system_error的另一个定义在哪里,我不明白?

0 个答案:

没有答案