繁体   English   中英

(CMake构建)致命错误LNK1181:无法打开输入文件'glew.lib'

[英](CMake build) fatal error LNK1181: cannot open input file 'glew.lib'

我正在开发游戏引擎,最近尝试创建CMakeLists.txt来构建项目。 我设法创建一个配置并生成的cmakelist,但是当我尝试在Visual Studio中运行generate .sln时,出现以下错误:

fatal error LNK1181: cannot open input file 'glew.lib'

我的游戏引擎使用外部库glew和glfw。 这是我的cmakelist文件:

cmake_minimum_required(VERSION 3.7)
project(GameEngine)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/Engine/source)

set(ENGINE_SOURCES ${SOURCE_DIR}/core/Engine.cpp
           ${SOURCE_DIR}/graphics/gl_types/IndexBuffer.cpp
           ${SOURCE_DIR}/graphics/gl_types/VertexArray.cpp
           ${SOURCE_DIR}/graphics/gl_types/VertexBuffer.cpp
           ${SOURCE_DIR}/graphics/renderer/Camera.cpp
           ${SOURCE_DIR}/graphics/renderer/Shader.cpp
           ${SOURCE_DIR}/graphics/renderer/Texture.cpp
           ${SOURCE_DIR}/graphics/renderer/Window.cpp
           ${SOURCE_DIR}/vendor/stb_image/stb_image.cpp)

add_library(engine STATIC ${ENGINE_SOURCES})
target_include_directories(engine PUBLIC ${SOURCE_DIR})


set(glfw3_DIR ${CMAKE_SOURCE_DIR}/Dependencies/GLFW/lib/cmake/glfw3)
find_package(glfw3 REQUIRED)

set(glew_DIR ${CMAKE_SOURCE_DIR}/Dependencies/GLEW)
find_library(glew glew32s "${glew_DIR}/lib/Release/Win32")

include_directories(${GLFW_INCLUDE_DIRS})
include_directories(${glew_DIR}/include)

target_link_libraries(
        engine
        glfw
        glew
)

set(GAME_DIR ${CMAKE_SOURCE_DIR}/Game/source)
set(GAME_SOURCES ${GAME_DIR}/main.cpp)

add_executable(engine_game ${GAME_SOURCES})

target_link_libraries(engine_game engine)```

您正在使用find_library来设置变量。 您必须这样使用它们:

target_link_libraries(
        engine
        ${glfw_LIBRARIES}
        ${glew}
)

我假设glfw_LIBRARIESfind_package(glfw)设置的变量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM