0
我正在尝试创建一个C++ dll。我遵循了msdn教程,但我无法正确编译我的dll。不能用Visual Studio导出C++ dll
问题是任何函数都被导出。我已用dumpbin.exe
工具和nm
工具对其进行了测试。
在这两种情况下,都没有检测到符号。
下面是这个库的代码:
头文件
#ifndef NLIB_H
#define NLIB_H
#ifdef _WINDLL
#define NLIB_EXPORTS __declspec(dllexport)
#else
#define NLIB_EXPORTS __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"{
#endif
NLIB_EXPORTS int fun1(int n);
#ifdef __cplusplus
}
#endif
#endif
源代码文件:
#include "nlib.h"
int fun1(int n) {
return 100;
}
你定义'_WINDLL'当您生成的dll? – Thomas
是的,如果您选择动态库作为项目类型,则由Visual Studio定义。另外,VS 2013指出了哪些宏定义了,我确信'_WINDLL'正在工作。 – Dan
'_WINDLL'在哪里定义 - 在某个头文件中,还是在项目设置中? – Andy