(CMake 内部版本)致命错误LNK1181:无法打开输入文件'glew.lib'
(CMake build) fatal error LNK1181: cannot open input file 'glew.lib'
我正在开发一个游戏引擎,最近尝试创建一个CMakeLists.txt来构建项目。我设法创建了一个配置和生成的cmakelist,但是当我尝试在视觉工作室中运行生成.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_LIBRARIES
是find_package(glfw)
设置的变量。
相关文章:
- 用c++从输入文件中读取另一行
- 更改.cpp程序的输入文件中数据的位置会意外更改输出
- 获取通过重定向传入的输入文件的名称?
- C++ 如何打开带有另一个目录的输入文件?
- C++模板编程设计问题 - 根据输入文件返回不同的类型
- 如何从输入文件 c++ 创建随机名称生成器
- 从输入文件修剪空格
- 链接器输入文件未使用,因为链接未完成,我无法获得.o
- 我正在尝试从输入文件中读取,然后使用它们的子字符串比较字符串的特定部分
- 我遇到使用 c++ 逐行读取输入文件的问题
- 使用重定向命令从 stdin 读入的字符串"<"输入文件未正确附加
- 使用 getline 从输入文件打印时如何忽略空白行
- 如何按升序对输入文件中的数字进行排序,并找到它们的范围和中值
- 数组大小由输入文件中的行数定义
- 从C++输入文件读取
- 在课堂上创建了一个朋友,给出"无输入文件"错误
- 通过显示一行星号来创建条形图,该条形图将读取数据的输入文件
- 利用输入文件中的数据(字符串和int)并在循环中利用
- C++ 仅读取输入文件中的部分(不是全部)数据以添加到记录中
- 如何从输入文件中读取字符并将其存储到向量中?