CMake找不到GLEW库

wtlkbnrh  于 2023-10-20  发布在  其他
关注(0)|答案(1)|浏览(173)

我有一个问题与建设CMake项目与GLEW。在这个网站上解决了类似名称的问题之后,我登陆了以下CmakeLists.txt:

set(GLEW_DIR "ext/glew-2.2.0")

set(GLEW_INCLUDE_DIR "ext/glew-2.2.0/include")
set(GLEW_LIBRARY "ext/glew-2.2.0/lib/Release/Win32")
set(GLEW_LIBRARIES "ext/glew-2.2.0/lib/Release/x64/glew32")

# Find OpenGL package (required for GLEW)
#find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)

target_link_libraries(engine PUBLIC kgfw PUBLIC glfw PUBLIC glm box2d PUBLIC freetype PUBLIC glfont PUBLIC ${GLEW_LIBRARY}

错误类型:
找不到GLEW(缺少:GLEW_INCLUDE_DIRS GLEW_LIBRARIES)CMakeLists.txt:47(find_package)
删除find_package允许它生成,但会产生编译错误:
错误LNK1104无法打开文件“ext\glew 2.2.0\lib\Release\Win32.lib”
这是正确的文件位置,但找不到库。我被卡住了。我从官方网站下载了2.2.0。我是不是漏掉了什么?Wikihow和其他在线教程似乎没有遇到这个障碍,他们的例子也没有运行。

a1o7rhls

a1o7rhls1#

解决方案是拥有以下CMakeLists:

set(GLEW_INCLUDE_DIR "ext/glew-2.2.0/include")

set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/glew-2.2.0)

target_link_libraries(engine PUBLIC ${GLEW_LIBRARY})

相关问题