Я работал над изучением OpenGL на Windows-машине с MinGW, и мне удалось скомпилировать и запустить программу OpenGL, используя стандартные include, glu32.dll и т. Д. На этот раз я пытаюсь скомпилировать базовый шейдерчто казалось бы достаточно простым, если бы я использовал GLFW, GLAD, GLM и их соответствующие зависимости.Я думаю, что у меня есть все, кроме GLFW должным образом.
Мой Makefile:
all:
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c deps/glad/*.c
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c src/common/*.cpp
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c src/objects/*.cpp
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c src/objects/mesh/*.cpp
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c src/*.cpp
g++ -Wall -g *.o -o run$(EXEEXT) -L ./ -lgdi32 -lglut32 -lglu32 -lopengl32 -lglfw3
make clean
clean:
cmd.exe /c del *.o
Запуск этого , однако дает ошибки связывания для функций изGLFW
C:\Users\plore\Desktop\app>make
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c deps/glad/*.c
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c src/common/*.cpp
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c src/objects/*.cpp
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c src/objects/mesh/*.cpp
g++ -Wall -Wno-unknown-pragmas -Wno-unused-function -g -c src/*.cpp
In file included from c:\users\plore\desktop\app\deps\glm\detail/func_exponential_simd.inl:4:0,
from c:\users\plore\desktop\app\deps\glm\detail/func_exponential.inl:150,
from c:\users\plore\desktop\app\deps\glm\exponential.hpp:110,
from c:\users\plore\desktop\app\deps\glm\detail/func_geometric.inl:1,
from c:\users\plore\desktop\app\deps\glm\geometric.hpp:116,
from c:\users\plore\desktop\app\deps\glm\detail/func_matrix.inl:1,
from c:\users\plore\desktop\app\deps\glm\matrix.hpp:161,
from src/shader/../../deps/glm/./ext/../detail/type_mat2x2.inl:1,
from src/shader/../../deps/glm/./ext/../detail/type_mat2x2.hpp:176,
from src/shader/../../deps/glm/./ext/matrix_double2x2.hpp:5,
from src/shader/../../deps/glm/mat2x2.hpp:5,
from src/shader/../../deps/glm/glm.hpp:119,
from src/shader/shader_s.h:15,
from src/main.cpp:20:
c:\users\plore\desktop\app\deps\glm\simd\exponential.h: In function 'glm_f32vec4 glm_vec1_sqrt_lowp(glm_f32vec4)':
c:\users\plore\desktop\app\deps\glm\simd\exponential.h:10:64: warning: SSE vector return without SSE enabled changes the ABI [-Wpsabi]
GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec1_sqrt_lowp(glm_f32vec4 x)
^
g++ -Wall -g *.o -o run -L ./ -lgdi32 -lglut32 -lglu32 -lopengl32 -lglfw3
Warning: resolving ___glutInitWithExit@12 by linking to ___glutInitWithExit
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving ___glutCreateWindowWithExit@8 by linking to ___glutCreateWindowWithExit
Warning: resolving ___glutCreateMenuWithExit@8 by linking to ___glutCreateMenuWithExit
Warning: resolving _glPushMatrix@0 by linking to _glPushMatrix
Warning: resolving _glTranslatef@12 by linking to _glTranslatef
Warning: resolving _glRotatef@16 by linking to _glRotatef
Warning: resolving _glPopMatrix@0 by linking to _glPopMatrix
Warning: resolving _glColor3f@12 by linking to _glColor3f
Warning: resolving _glBegin@4 by linking to _glBegin
Warning: resolving _glVertex2f@8 by linking to _glVertex2f
Warning: resolving _glEnd@0 by linking to _glEnd
main.o: In function `Z12processInputP10GLFWwindow':
C:\Users\plore\Desktop\app/src/main.cpp:35: undefined reference to `_imp__glfwGetKey'
C:\Users\plore\Desktop\app/src/main.cpp:36: undefined reference to `_imp__glfwSetWindowShouldClose'
main.o: In function `main':
C:\Users\plore\Desktop\app/src/main.cpp:121: undefined reference to `_imp__glfwInit'
C:\Users\plore\Desktop\app/src/main.cpp:122: undefined reference to `_imp__glfwWindowHint'
C:\Users\plore\Desktop\app/src/main.cpp:123: undefined reference to `_imp__glfwWindowHint'
C:\Users\plore\Desktop\app/src/main.cpp:124: undefined reference to `_imp__glfwWindowHint'
C:\Users\plore\Desktop\app/src/main.cpp:132: undefined reference to `_imp__glfwCreateWindow'
C:\Users\plore\Desktop\app/src/main.cpp:136: undefined reference to `_imp__glfwTerminate'
C:\Users\plore\Desktop\app/src/main.cpp:139: undefined reference to `_imp__glfwMakeContextCurrent'
C:\Users\plore\Desktop\app/src/main.cpp:140: undefined reference to `_imp__glfwSetFramebufferSizeCallback'
C:\Users\plore\Desktop\app/src/main.cpp:144: undefined reference to `_imp__glfwGetProcAddress'
C:\Users\plore\Desktop\app/src/main.cpp:255: undefined reference to `_imp__glfwWindowShouldClose'
C:\Users\plore\Desktop\app/src/main.cpp:279: undefined reference to `_imp__glfwSwapBuffers'
C:\Users\plore\Desktop\app/src/main.cpp:280: undefined reference to `_imp__glfwPollEvents'
C:\Users\plore\Desktop\app/src/main.cpp:291: undefined reference to `_imp__glfwTerminate'
collect2.exe: error: ld returned 1 exit status
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1
C:\Users\plore\Desktop\app>
Из-за того, что читал о проблемах других людей по этому вопросу, кажется, что проблема с компилятором, который не находит libglfw3.a и libglfw3dll.a, которые я поместил в тот же каталог, что и все остальные dll.
Это содержимое моего каталога , где src имеет мой main.cpp, а deps - заголовки для включений.
C:\Users\plore\Desktop\app>dir
Volume in drive C has no label.
Volume Serial Number is 9CEF-2A78
Directory of C:\Users\plore\Desktop\app
11/29/2018 07:46 PM <DIR> .
11/29/2018 07:46 PM <DIR> ..
11/29/2018 07:39 PM <DIR> deps
08/18/2016 06:04 AM 238,974 glfw3.dll
11/27/2018 04:26 PM 245,760 glu32.dll
11/27/2018 04:26 PM 237,568 glut32.dll
08/18/2016 06:05 AM 150,452 libglfw3.a
08/18/2016 06:05 AM 65,788 libglfw3dll.a
11/29/2018 07:43 PM 515 Makefile
11/27/2018 04:26 PM 757,248 opengl32.dll
11/27/2018 04:26 PM 55 README.md
11/29/2018 12:10 PM <DIR> src
8 File(s) 1,696,360 bytes
4 Dir(s) 27,734,446,080 bytes free
C:\Users\plore\Desktop\app>
Любая помощь будет принята с благодарностью.Спасибо.
Обновление: Я пробовал разные заказы со связанными библиотеками, но они не оказали никакого влияния.Однако, что интересно, удаление libglfw3.a
и libglfw3dll.a
позволяет программе компилироваться только для мгновенного сбоя.Отладка с помощью GDB дает следующее
C:\Users\plore\Desktop\app>gdb
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file run.exe
Reading symbols from C:\Users\plore\Desktop\app\run.exe...done.
(gdb) r
Starting program: C:\Users\plore\Desktop\app/run.exe
[New Thread 13120.0x3c3c]
[New Thread 13120.0x38a8]
[New Thread 13120.0x2b08]
[New Thread 13120.0x37bc]
[New Thread 13120.0x828]
[New Thread 13120.0x2810]
[New Thread 13120.0x39d0]
[New Thread 13120.0x3c34]
[New Thread 13120.0x1610]
[New Thread 13120.0x268c]
[New Thread 13120.0x3600]
[New Thread 13120.0x319c]
[New Thread 13120.0x34d8]
[New Thread 13120.0x15ec]
Program received signal SIGSEGV, Segmentation fault.
0x692b1d25 in _glfwRefreshContextAttribs () from C:\Users\plore\Desktop\app\glfw3.dll
(gdb) where
#0 0x692b1d25 in _glfwRefreshContextAttribs () from C:\Users\plore\Desktop\app\glfw3.dll
#1 0x63f1f3ff in wglSwapLayerBuffers () from C:\Users\plore\Desktop\app\opengl32.dll
#2 0x00003c3c in ?? ()
#3 0x63f1f632 in wglSwapLayerBuffers () from C:\Users\plore\Desktop\app\opengl32.dll
#4 0x36384224 in ?? ()
#5 0x0068fcf8 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)