声明的Hello World DLL文件.运行时未找到外部函数

Declared Hello World DLL File. External Function Not Found at run-time

本文关键字:外部 函数 运行时 文件 Hello World DLL 声明      更新时间:2023-10-16

最初发布在这里(https://stackoverflow.com/questions/32617735/declared-dll-but-errors-external-function-not-found),但被告知不使用类或命名空间。转发一个简单的例子,我仍然不能去工作。

用c++ (Visual Studio)制作的DLL:
// myFirstDLL.h
#define DECLDIR __declspec(dllexport)
DECLDIR int GIMMEFIVE();

// myFirstDLL.cpp
#include "stdafx.h"
#include "myFirstDLL.h"
#include <stdexcept>
//using namespace std;
int GIMMEFIVE()
{
    return 5;
}

LotusScript代理:

Option Public
Option Declare
Declare Public Function GIMMEFIVE Lib "P:InternetdplowsvisualstudiomyFirstDLLmyFirstDLLDebugmyFirstDLL.dll" () As Integer
Sub Initialize
    MsgBox GIMMEFIVE()
End Sub

要求将函数封装在extern "C"块中;

extern "C"
{
    extern __declspec(dllexport) int GIMMEFIVE();
}

同时声明为extern "C"__declspec(dllexport)。如果您自己不从DLL中调用该函数,则不需要转发声明它。

extern "C" __declspec(dllexport) int GIMMEFIVE()
{
    return 5;
}