我曾使用GLFW学习OpenGL,当时对makefiles并不是很了解。虽然OpenGL可以运行,但我决定更深入地学习makefiles。经过多个网站的参考、数小时的学习和尝试,我总结出以下内容:
EXENAME = "OpenGL Demo"
CC = gcc
SRCS = ../src/OpenGLDemo.c
OBJS = $(SRCS: .c = .o)
CFLAGS = -Wall -g -c
LIBS = -L./libs -lglfw3 C:/Windows/SysWOW64/opengl32.dll C:/Windows/SysWOW64/glu32.dll
all: opengldemo exe
exe: $(OBJS)
$(CC) $(OBJS) -o $(EXENAME) $(LIBS)
opengldemo: ../src/OpenGLDemo.c
$(CC) $(CFLAGS) ../src/OpenGLDemo.c
clean:
rm -f $(EXENAME)
rebuild: clean all
但是,当我编译时,在尝试构建可执行文件时会出现以下错误:
collect2: error: ld terminated with signal 11 [Segmentation fault], core dumped
makefile:11: recipe for target 'exe' failed
make: *** [exe] Error 1
它确实构建了一个可执行文件,但我的计算机却无法运行它。我尝试搜索互联网,并找到了包括此错误的gcc错误报告。我可能做了一些愚蠢的事情导致这个错误。我该怎么解决这个错误,它是什么意思?
编辑:完整输出:
make
gcc -Wall -g -c ../src/OpenGLDemo.c
gcc ../src/OpenGLDemo.c -o "OpenGL Demo" -L./libs -lglfw3
C:/Windows/SysWOW64/opengl32.dll C:/Windows/SysWOW64/glu32.dll
cygwin warning:
MS-DOS style path detected: C:/Windows/SysWOW64/opengl32.dll
Preferred POSIX equivalent is: /cygdrive/c/Windows/SysWOW64/opengl32.dll
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
collect2: error: ld terminated with signal 11 [Segmentation fault], core dumped
makefile:11: recipe for target 'exe' failed
make: *** [exe] Error 1