我正在尝试将clion上的glew和glfw与cmake联系起来。我是通过visual studio easilly完成的,但我遇到了clion的问题。这就是我如何包含我的依赖项,如glew(.dll不应该在那里我猜):
这是我的cmake文件。
cmake_minimum_required(VERSION 3.6)
project(Course)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
find_package(OpenGL REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/libs)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/libs)
set(SOURCE_FILES main.cpp Window.cpp Window.h)
add_executable(Course ${SOURCE_FILES})
target_link_libraries(Course ${OPENGL_LIBRARY} libglew32.a libglfw3.a )
错误:
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x42c): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x448): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x464): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x478): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x48c): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x4a0): more undefined references to `wglGetProcAddress@4' follow
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1de1f): undefined reference to `wglGetCurrentDC@0'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1de8f): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1dea3): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1debe): undefined reference to `wglGetCurrentDC@0'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1df3a): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e0c0): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e0dc): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e0fa): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e4dc): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e4f8): more undefined references to `wglGetProcAddress@4' follow
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x20352): undefined reference to `glGetString@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x204d4): undefined reference to `glGetIntegerv@8'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x204e3): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x2055e): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x2057a): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x20596): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x205ac): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x20665): more undefined references to `wglGetProcAddress@4' follow
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26e21): undefined reference to `glGetString@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f31): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f47): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f60): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f7b): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f8f): undefined reference to `wglGetProcAddress@4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26fa3): more undefined references to `wglGetProcAddress@4' follow
好像cmake找不到glew(但我告诉它glew在哪里?):
编辑:
在target_link_libraries结尾处添加$ {OPENGL_LIBRARIES}
cmake_minimum_required(VERSION 3.6)
project(Course)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
find_package(OpenGL REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/libs)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/include/GL)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/libs)
set(SOURCE_FILES main.cpp Window.cpp Window.h)
add_executable(Course ${SOURCE_FILES})
target_link_libraries(Course glfw3.a libglew32.a ${OPENGL_LIBRARIES})