1
我想從使用Visual Studio的C++代碼調用R函數。代碼如下。我收到以下錯誤:集成來自C++的R代碼
"error LNK2019: unresolved external symbol _Rf_initEmbeddedR referenced in function _main"
我找不到"_Rf_initEmbeddedR"
的定義。任何人都可以幫助如何整合R與C++代碼?
enter code here
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include "Rinternals.h"
#include "Rembedded.h"
SEXP hello() {
return mkString("Hello, world!\n");
}
int main(int argc, char **argv)
{
SEXP x;
Rf_initEmbeddedR(argc, argv);
x = hello();
return 0;
}
@Sergey:我看到堆棧溢出的一個線程,那裏有一個來自Sergey的評論,他說他能夠構建R.lib並將其鏈接到visual studio。任何人都可以詳細闡述它。鏈接:https://stackoverflow.com/questions/2463437/r-from-c-simplest-possible-helloworld – AKJ