无法在使用Visual Studio编译的dyn.load中加载R

时间:2013-12-15 08:41:01

标签: c r visual-studio-2012 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的小例子。 我的想法已经不多了。有人可以帮忙吗?

file 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

0 个答案:

没有答案