GLEW-为什么要定义GLEW_STATIC? [英] GLEW - why should I define GLEW_STATIC?
问题描述
我正在为GLEW使用静态链接库,因此必须定义GLEW_STATIC来编译使用GLEW的程序.但是我从来不明白为什么这样做是必要的.有人可以解释原因吗?
I am using a statically linked library for GLEW and therefore I have to define GLEW_STATIC to compile my programs that are using GLEW. But I have never understood why this is necessary. So could anyone explain the reason?
推荐答案
由静态库导出或从静态库导入的函数的签名用关键字 extern __declspec(dllimport)
. GLEW_STATIC
是激活第一种情况的预处理器定义.
The signature of a function which is exported by or imported from a static library is marked by the keyword export
. A function which is imported from a dynamic library has to be marked by extern __declspec(dllimport)
. GLEW_STATIC
is a preprocessor definition which activates the first case.
"glew.h"文件(版本2.1.0)中的相关代码部分为:
The relevant code part in the "glew.h" file (verison 2.1.0) is:
/*
* GLEW_STATIC is defined for static library.
* GLEW_BUILD is defined for building the DLL library.
*/
#ifdef GLEW_STATIC
define GLEWAPI extern
#else
ifdef GLEW_BUILD
define GLEWAPI extern __declspec(dllexport)
else
define GLEWAPI extern __declspec(dllimport)
endif
#endif
这篇关于GLEW-为什么要定义GLEW_STATIC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!