我试图通过将GLFW源代码直接包含到我的项目(没有lib或dll)并编译它来编译GLFW。
下面是我试过的一个简单例子:
#include <iostream>
#define _GLFW_WIN32
#include <glad/glad.h>
#include <GLFW\glfw3.h>
int main(int argc, const char *argv[])
{
return 0;
}在glfw3.h中定义的所有路径都是正确的,正如您可以看到的,我已经定义了宏_GLFW_WIN32 (根据https://www.glfw.org/docs/3.1/compile.html),但是,在编译时,我得到了以下错误:
C:\GLFW\code\内在.h (194):致命错误C1189:# error:“不支持所选的窗口创建API”
当查看内部.h(第183行)时:
#if defined(_GLFW_COCOA)
#include "cocoa_platform.h"
#elif defined(_GLFW_WIN32)
#include "win32_platform.h"
#elif defined(_GLFW_X11)
#include "x11_platform.h"
#elif defined(_GLFW_WAYLAND)
#include "wl_platform.h"
#elif defined(_GLFW_OSMESA)
#include "null_platform.h"
#else
#error "No supported window creation API selected"
#endif这是没有意义的,因为我定义了_GLFW_WIN32。知道我做错什么了吗?
发布于 2020-04-29 18:17:06
我发现了这个问题,使用#define宏是不够的,因为glfw将在我的主要代码之前编译。
我解决这个问题的方法是使用
-D _GLFW_WIN32
编译命令行中的符号
https://stackoverflow.com/questions/61483915
复制相似问题