Cannot load in R with dyn.load a dll compiled with Visual Studio

I cannot load dlls that I compile with Visual Studio in Win XP sp3 or Win7. I set the current directory in the path environment. When I try to dyn.load it I get the error message:

" Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'C:/Documents and Settings//[.....]//sampleDLL.dll': LoadLibrary failure: The specified module could not be found. "

Obviously the dll is there, the error refers to something else missing.

I can call the dll from C. Below I attach a small example of a dll that cannot be loaded in R. I am running out of ideas. Can someone help?

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);
}

end 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);

end sampleDLL.h

链接地址: http://www.djcxy.com/p/26824.html

上一篇: dyn.load()中的错误:无法加载共享对象

下一篇: 不能在R中加载dyn.load用Visual Studio编译的dll