LNK1104 无法打开文件“hello_library.lib"

890 阅读1分钟

问题:

vs2019 cmake工程shared类型类库生成dll,target_link_libraries无法链接

解决:

windows导出需要在头文件加如下代码

#ifndef __HELLO_H__
#define __HELLO_H__

#define DllImport   __declspec( dllimport )
#define DllExport   __declspec( dllexport )

class DllExport Hello
{
public:
    void print();
};

#endif

参考: