GL/glew.h: glew.c 中没有这样的文件或目录
GL/glew.h: No such file or directory in glew.c
当我尝试编译我的程序时出现此错误
C:\...\CLionProjects\Radix\vendors\glew-2.1.0\src\glew.c:34:10: fatal error: GL/glew.h: No such file or directory
#include <GL/glew.h>
^~~~~~~~~~~
错误在库代码中,我这里做错了什么?
我的项目结构如下所示:
Radix
|- Radix-core
|- cpp code..
|- vendors
|- CMakeLists.txt
|- glew-2.1.0
|- Other libs..
- CMakeLists.txt
CMakeLists.txt(只是闪亮部分)
add_subdirectory(vendors)
add_definitions(-DTW_STATIC -DTW_NO_LIB_PRAGMA -DTW_NO_DIRECT3D -DGLEW_STATIC -D_CRT_SECURE_NO_WARNINGS)
# Including GLEW
include_directories(vendors/glew-2.1.0/include)
set(ALL_LIBS opengl32 glfw GLEW_210)
target_link_libraries(Radix ${ALL_LIBS})
vendors/CMakeLists.txt(只是glew部分)
add_definitions(-DTW_STATIC -DTW_NO_LIB_PRAGMA -DTW_NO_DIRECT3D -DGLEW_STATIC -D_CRT_SECURE_NO_WARNINGS)
### GLEW ###
set(GLEW_HEADERS)
set(GLEW_SOURCE glew-2.1.0/src/glew.c)
set(GLEW_INCLUDE glew-2.1.0/include)
add_library(GLEW_210 ${GLEW_SOURCE} ${GLEW_INCLUDE})
target_link_libraries(GLEW_210 ${OPENGL_LIBRARY} ${EXTRA_LIBS})
将您的包含目录添加到 GLEW_210 的源文件中没有任何作用。而是将其添加为 PUBLIC 包含目录,因此 glew.c
的编译也可以访问 glew headers:
target_include_directories(GLEW_210 PUBLIC glew-2.1.0/include)
这还会将包含目录传播到 link 和 GLEW_210 的任何目标,因此您可以在主 CMakeLists.txt[=13] 中删除 include_directories
语句=]
当我尝试编译我的程序时出现此错误
C:\...\CLionProjects\Radix\vendors\glew-2.1.0\src\glew.c:34:10: fatal error: GL/glew.h: No such file or directory
#include <GL/glew.h>
^~~~~~~~~~~
错误在库代码中,我这里做错了什么?
我的项目结构如下所示:
Radix
|- Radix-core
|- cpp code..
|- vendors
|- CMakeLists.txt
|- glew-2.1.0
|- Other libs..
- CMakeLists.txt
CMakeLists.txt(只是闪亮部分)
add_subdirectory(vendors)
add_definitions(-DTW_STATIC -DTW_NO_LIB_PRAGMA -DTW_NO_DIRECT3D -DGLEW_STATIC -D_CRT_SECURE_NO_WARNINGS)
# Including GLEW
include_directories(vendors/glew-2.1.0/include)
set(ALL_LIBS opengl32 glfw GLEW_210)
target_link_libraries(Radix ${ALL_LIBS})
vendors/CMakeLists.txt(只是glew部分)
add_definitions(-DTW_STATIC -DTW_NO_LIB_PRAGMA -DTW_NO_DIRECT3D -DGLEW_STATIC -D_CRT_SECURE_NO_WARNINGS)
### GLEW ###
set(GLEW_HEADERS)
set(GLEW_SOURCE glew-2.1.0/src/glew.c)
set(GLEW_INCLUDE glew-2.1.0/include)
add_library(GLEW_210 ${GLEW_SOURCE} ${GLEW_INCLUDE})
target_link_libraries(GLEW_210 ${OPENGL_LIBRARY} ${EXTRA_LIBS})
将您的包含目录添加到 GLEW_210 的源文件中没有任何作用。而是将其添加为 PUBLIC 包含目录,因此 glew.c
的编译也可以访问 glew headers:
target_include_directories(GLEW_210 PUBLIC glew-2.1.0/include)
这还会将包含目录传播到 link 和 GLEW_210 的任何目标,因此您可以在主 CMakeLists.txt[=13] 中删除 include_directories
语句=]