如何解决collect2.exe:错误:ld 返回 1 退出状态未创建 DLL
您好,我正在尝试使用 Rcpp 在 R 中制作一个包。 当我只有一个文件时,一切正常,我的包(foad2)已完全编译。 但是,当我有多个.cpp文件(它们不相互依赖,每个文件只包含一个函数)时,我会遇到以下错误
C:/RBuildTools/3.5/mingw_64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.3/include" -DNDEBUG -I"C:/Users/Foad/Documents/R/win-library/3.6/Rcpp/include" -O2 -Wall -mtune=core2 -c myFunc.cpp -o myFunc.o
C:/RBuildTools/3.5/mingw_64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.3/include" -DNDEBUG -I"C:/Users/Foad/Documents/R/win-library/3.6/Rcpp/include" -O2 -Wall -mtune=core2 -c rcpp_hello_world.cpp -o rcpp_hello_world.o
C:/RBuildTools/3.5/mingw_64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o foad2.dll tmp.def RcppExports.o myFunc.o rcpp_hello_world.o -LC:/PROGRA~1/R/R-36~1.3/bin/x64 -lR
RcppExports.o:RcppExports.cpp:(.rdata+0x6f8): undefined reference to `_foad2_rcpp_myFunc'
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'foad2'
* removing 'C:/Users/Foad/Documents/R/win-library/3.6/foad2'
Exited with status 1.
我的 Cpp 代码是:
我的第一个 cpp 文件:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
List rcpp_hello_world() {
CharacterVector x = CharacterVector::create( "foo","bar" ) ;
NumericVector y = NumericVector::create( 0.0,1.0 ) ;
List z = List::create( x,y ) ;
return z ;
}
我的第二个 cpp 文件:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector myFunc(NumericVector x) {
return x * 2;
}
如果有人告诉我如何解决这个问题,我会很高兴的?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。