使用 Visual Studio 构建 dll

build dlls using Visual Studio

本文关键字:dll 构建 Studio Visual 使用      更新时间:2023-10-16

我想使用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() 之前有返回类型

将其移至

PRC50CONTROL_API int SetPRC50Gain(double inGain);

另外,显然,请确保您有

PRC50CONTROL_EXPORTS

在要从中导出符号的库的标题中定义。