我有一个简单的DLL:
这里是.h文件:
#ifdef WIN32PROJECT3_EXPORTS
#define WIN32PROJECT3_API __declspec(dllexport)
#else
#define WIN32PROJECT3_API __declspec(dllimport)
#endif
// This class is exported from the Win32Project3.dll
class WIN32PROJECT3_API CWin32Project3 {
public:
CWin32Project3(void);
// TODO: add your methods here.
};
extern WIN32PROJECT3_API int nWin32Project3;
WIN32PROJECT3_API int pippo(int value);
这里是.cpp文件:
#include "stdafx.h"
#include "Win32Project3.h"
WIN32PROJECT3_API int nWin32Project3=0;
// This is an example of an exported function.
WIN32PROJECT3_API int pippo(int value)
{
return 42 * value;
}
// This is the constructor of a class that has been exported.
// see Win32Project3.h for the class definition
CWin32Project3::CWin32Project3()
{
return;
}
这是Ruby方面:
require 'ffi'
module TestModule
extend FFI::Library
ffi_lib 'Win32Project3'
attach_function :pippo, [:int], :int
end
Ruby没有找到导出的int pippo(int value)
方法。它成功加载DLL但无法找到该功能。这个错误非常自我解释,但并不能说明造成错误的原因。
这是来自ruby控制台的实际错误字符串:
功能' pippo'在[Win32Project3]中找不到(FFI:NotFoundError)