不能在R中加载dyn.load用Visual Studio编译的dll
我无法加载在Win XP sp3或Win7中使用Visual Studio编译的dll。 我在路径环境中设置当前目录。 当我尝试dyn.load时,我收到错误消息:
“inDL(x,as.logical(local),as.logical(now),...)中的错误:无法加载共享对象'C:/ Documents and Settings //[.....]// sampleDLL .dll':LoadLibrary失败:无法找到指定的模块。“
很显然,DLL在那里,错误指的是别的东西丢失。
我可以从C中调用dll。下面我附上一个不能在R中加载的dll的小例子。我正在用尽想法。 有人可以帮忙吗?
文件sampleDLL.c
#include <windows.h>
#include <stdio.h>
#include "SampleDLL.h"
double PowerOf2 (double UserNumber)
{
printf("Complete the Power of 2");
return UserNumber * UserNumber;
}
double PowerOf3 (double UserNumber)
{
printf("Complete the Power of 3");
return UserNumber * UserNumber * UserNumber;
}
double CircleArea (double UserRadius)
{
printf("Complete the CircleArea");
return UserRadius * UserRadius * PI;
}
double CircleCircum (double UserRadius)
{
printf("Complete the CircleCircum");
return 2 * UserRadius * PI;
}
void MyFunc(char ** strInput)
{
printf("Complete the MyFunc");
MessageBox(0, L"Hi Viet from C", L"C Program", 0);
}
结束sampleDLL.c
sampleDLL.h
#ifdef SAMPLEDLL_EXPORTS
#define SAMPLEDLL_API __declspec(dllexport)
#else
#define SAMPLEDLL_API __declspec(dllimport)
#endif
#define PI 3.1415
SAMPLEDLL_API double PowerOf2 (double UserNumber);
SAMPLEDLL_API double PowerOf3 (double UserNumber);
SAMPLEDLL_API double CircleArea (double UserRadius);
SAMPLEDLL_API double CircleCircum (double UserRadius);
SAMPLEDLL_API void MyFunc(char ** strInput);
结束sampleDLL.h
链接地址: http://www.djcxy.com/p/26823.html上一篇: Cannot load in R with dyn.load a dll compiled with Visual Studio