使用 Visual Studio 构建 dll

build dlls using Visual Studio

我想使用 Visual Studio 构建 dll,我想将其用作 Matlab 中的函数。

这样做时我使用了 declspec(dllimport) 函数...但是我得到编译错误 LNK2019: 未解析的外部 sumbol?

感谢您的帮助。

#ifdef PRC50CONTROL_EXPORTS
#define PRC50CONTROL_API __declspec(dllexport)
#else
#define PRC50CONTROL_API __declspec(dllimport)
#endif


int PRC50CONTROL_API SetPRC50Gain(double inGain);
int PRC50CONTROL_API SetPRC50Gain(double inGain);

您在 __declspec()

之前输入了 return

移至

PRC50CONTROL_API int SetPRC50Gain(double inGain);

此外,显然,请确保您有

PRC50CONTROL_EXPORTS

在您要从中导出符号的库的 header 中定义。