gpt4 book ai didi

c++ - 声明的 Hello World DLL 文件。运行时未找到外部函数

转载 作者:行者123 更新时间:2023-11-30 02:36:29 26 4
gpt4 key购买 nike

最初发布于此(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:\Internet\dplows\visualstudio\myFirstDLL\myFirstDLL\Debug\myFirstDLL.dll" () As Integer

Sub Initialize
MsgBox GIMMEFIVE()

End Sub

最佳答案

函数需要包裹在extern "C" block 中;

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

关于c++ - 声明的 Hello World DLL 文件。运行时未找到外部函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32630481/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com