- 开发环境 : CLion
- 编译器 : MinGW64
一、编写 dll
建立一个 C Library 项目 hello

library.c 文件中已有默认代码

ctrl + F9 编译
右侧生成了 libhello.dll 文件

二、调用 dll
另建立一个项目 Demo,在其根目录下建立 lib 目录,将上一步生成的 dll 文件拷入

main.cpp 内写入代码
#include <iostream>
#ifdef __cplusplus
extern "C" {
#endif
void hello();
#ifdef __cplusplus
}
#endif
int main() {