我想使用Rcpp编写一个C++函数,该函数使用包“hypred”中的C函数。该包可以在CRAN这里找到。
我阅读了在Rcpp中使用其他包中的C函数,但不确定是否适用于我的情况,如果适用,则该怎么做。
所需函数位于源文件/src/hypredRoutines.c中,名称为meiosisFUNAllChr。
基于此SO问题,我所做的是:
我阅读了在Rcpp中使用其他包中的C函数,但不确定是否适用于我的情况,如果适用,则该怎么做。
所需函数位于源文件/src/hypredRoutines.c中,名称为meiosisFUNAllChr。
基于此SO问题,我所做的是:
- I separated the function meiosisFUNAllChr from the rest of the code and placed it in a new file called meiosisFUNAllChr.c.
I created a header file called meiosisFUNAllChr.h containing:
#ifndef MEIOSISFUNALLCHR_H #define MEIOSISFUNALLCHR_H void meiosisFUNallChr (...); #endif
Compiled it with
gcc -c -o meiosisFUNAllChr.o meiosisFUNAllChr.c
Created a dummy c++ function
#include <Rcpp.h> using namespace Rcpp; extern "C" { #include "meiosisFUNallChr.h" } // [[Rcpp::export]] int timesTwo(int x) { return x * 2; }
目前,使用sourceCpp编译不起作用。你能告诉我如何让它工作吗?
非常感谢!
编辑
使用sourceCpp编译会出现以下错误:
meiosisFUNallChr.h: file or directory not found
sourceCpp
吗? - Dominic Comtois