gpt4 book ai didi

c++ - 尝试在 Windows 上的 CLion+CMake+MinGW 中编译 OpenGL 4 Helloworld。 "undefined reference to ` _imp____glewCreateShader'“错误

转载 作者:行者123 更新时间:2023-11-30 05:48:55 41 4
gpt4 key购买 nike

<分区>

谷歌搜索告诉我这是“错误的 VS 库”,但是当尝试使用 glew-1.5.4-mingw32libgluew32.a 而不是 glew32 时.lib(对 glut 也是如此)没有任何改变。

ma​​in.cpp 从 VS2012 上的项目中获取,附加相同的库,所以它可能没有错。

我用来制作的一些文件:

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.4)
project(HelloGL)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

add_executable(HelloGL main.cpp)

set(LIBS_DIR D:/libs)

set(GLEW_ROOT_DIR ${LIBS_DIR}/glew-1.5.4-mingw32 )
set(GLUT_ROOT_DIR ${LIBS_DIR}/glut-3.7.6-src/glut-3.7.6 )

set(GLEW_INCLUDE_DIRS ${GLEW_ROOT_DIR}/include)
set(GLUT_INCLUDE_DIRS ${GLUT_ROOT_DIR}/include)

set(GLEW_LIBRARY ${GLEW_ROOT_DIR}/lib/libglew32.a)
set(GLUT_LIBRARY ${GLUT_ROOT_DIR}/lib/glut/libglut32.a)


include_directories( ${GLEW_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} )

target_link_libraries(HelloGL ${GLEW_LIBRARY} ${GLUT_LIBRARY} )

部分日志:

 "D:\Tools\CLion 140.569.17\bin\cmake\bin\cmake.exe" --build C:\Users\Alexey\.clion10\system\cmake\generated\dc6fcb22\dc6fcb22\Debug --target HelloGL -- -j 8
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Alexey/.clion10/system/cmake/generated/dc6fcb22/dc6fcb22/Debug
Linking CXX executable HelloGL.exe
CMakeFiles\HelloGL.dir/objects.a(main.cpp.obj): In function `Z11LoadShadersPKcS0_':
D:/Projects/CPP/HelloGL/main.cpp:19: undefined reference to `_imp____glewCreateShader'
D:/Projects/CPP/HelloGL/main.cpp:20: undefined reference to `_imp____glewCreateShader'
D:/Projects/CPP/HelloGL/main.cpp:56: undefined reference to `_imp____glewShaderSource'
D:/Projects/CPP/HelloGL/main.cpp:57: undefined reference to `_imp____glewCompileShader'
D:/Projects/CPP/HelloGL/main.cpp:60: undefined reference to `_imp____glewGetShaderiv'
D:/Projects/CPP/HelloGL/main.cpp:61: undefined reference to `_imp____glewGetShaderiv'
D:/Projects/CPP/HelloGL/main.cpp:64: undefined reference to `_imp____glewGetShaderInfoLog'

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com