我试图让我的R包传递R CMD检查中的新约束。我无法这样做,即使我在src下创建了应该进行注册调用的c代码
我使用了mystr db "I don't ", 34, "listen", 34, " to radio"
创建RGraphM_init.cpp(我使用了cpp,因为我在Makevars.win中有替换)
这是RGraphM_init.cpp
package_native_routine_registration_skeleton(".")
我用过
#include <R.h>
#include <Rinternals.h>
#include <stdlib.h> // for NULL
#include <R_ext/Rdynload.h>
/* .Call calls */
extern SEXP RGraphM_run_graph_match(SEXP, SEXP, SEXP);
static const R_CallMethodDef CallEntries[] = {
{"RGraphM_run_graph_match", (DL_FUNC) &RGraphM_run_graph_match, 3},
{NULL, NULL, 0}
};
void R_init_RGraphM(DllInfo *dll)
{
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
在NAMESPACE中 我假设.cpp包含注册函数将被SHLIB构建拾取,但它没有修复注意没有调用R_useDynamicSymbols和R_regiterRoutines
相关的Makevars.win片段是:
useDynLib(packagename, .registration=TRUE)
这给出了RGraphM_init未定义ref
的链接错误SOURCES= graphmatch_rcpp.cpp RcppExports.cpp RGraphM_init.cpp
OBJECTS= $(SOURCES:.cpp=.o) $(GRAPHM_OBJ_REL)
$(SHLIB): $(OBJECTS)
($(GRAPHM_OBJ_REL)是一大堆静态C对象 这是RcppExports.cpp
C:/RBUILD~1/3.4/mingw_32/bin/g++ -shared -s -static-libgcc -o RGraphM.dll tmp.def graphmatch_rcpp.o RcppExports.o RGraphM_init.o ./graphm/./algorithm_ca.o ./graphm/./algorithm_ext.o ./graphm/./algorithm_fsol.o ./graphm/./algorithm_iden.o ./graphm/./algorithm_lp.o ./graphm/./algorithm.o ./graphm/./algorithm_path.o ./graphm/./algorithm_qcv.o ./graphm/./algorithm_rand.o ./graphm/./algorithm_rank.o ./graphm/./algorithm_umeyama.o ./graphm/./algorithm_unif.o ./graphm/./experiment.o ./graphm/./graph.o ./graphm/./hungarian.o ./graphm/./rpc.o -LC:\tools\local\/lib -lgsl -lgslcblas -LC:\tools\local\lib/i386 -lgsl -lgslcblas -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.0/bin/i386 -lR
RGraphM_init.o:RGraphM_init.cpp:(.rdata+0x1c): undefined reference to `RGraphM_run_graph_match(SEXPREC*, SEXPREC*, SEXPREC*)'
这是run_graph_match代码
// Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <RcppGSL.h>
#include <Rcpp.h>
using namespace Rcpp;
// run_graph_match
Rcpp::List run_graph_match(const RcppGSL::Matrix& A, const RcppGSL::Matrix& B, const Rcpp::List& algorithm_params);
RcppExport SEXP RGraphM_run_graph_match(SEXP ASEXP, SEXP BSEXP, SEXP algorithm_paramsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const RcppGSL::Matrix& >::type A(ASEXP);
Rcpp::traits::input_parameter< const RcppGSL::Matrix& >::type B(BSEXP);
Rcpp::traits::input_parameter< const Rcpp::List& >::type algorithm_params(algorithm_paramsSEXP);
rcpp_result_gen = Rcpp::wrap(run_graph_match(A, B, algorithm_params));
return rcpp_result_gen;
END_RCPP
}