dll中全局变量在外部进行引用

在Windows中实际导出全局变量,您必须使用类似于export / import语法的语法,例如:

1 #ifdef COMPILING_THE_DLL
2 #define MY_DLL_EXPORT extern "C" __declspec(dllexport)
3 #else
4 #define MY_DLL_EXPORT extern "C" __declspec(dllimport)
5 #endif
6 
7 MY_DLL_EXPORT int my_global;

参考网址:

https://codeday.me/bug/20170811/55724.html

https://blog.csdn.net/mangobar/article/details/53390552

https://blog.csdn.net/silvervi/article/details/5055707

原文地址:https://www.cnblogs.com/ydxt/p/9425982.html