本文介绍了collect2:错误:ld 以信号 11 [Segmentation fault] 终止,核心转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 GLFW 学习 OpenGL,当时对 makefile 并没有很好的理解.我有 OpenGL 工作,但我决定更多地学习 makefile.经过很多网站、几个小时、反复试验,我想出了这个:

I was learning OpenGL using GLFW, and didn't have a great understanding of makefiles at the time. I had OpenGL working, but I decided to learn makefiles more. I came up with this after a lot of websites, hours, and trial and error:

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

但是,当我编译时,它会在尝试构建可执行文件时出现此错误:

But, when I compile, it gives this error when it tries to build the executable:

collect2: error: ld terminated with signal 11 [Segmentation fault], core dumped
makefile:11: recipe for target 'exe' failed
make: *** [exe] Error 1

它确实构建了一个可执行文件,但我的计算机说它无法运行它.我尝试搜索互联网,发现包括此错误的 gcc 错误报告.我可能正在做一些愚蠢的事情来得到这个错误.我该如何解决这个错误,这是什么意思?

It does build an executable, but my computer says it can't run it.I tried searching the internet, and found gcc bug reports including this error. There is probably something stupid that I am doing to get this error.How do I fix this error, and what does it mean?

完整输出:

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

推荐答案

这意味着 ld 工具或其依赖项之一存在导致无效内存访问(分段错误)的错误操作系统使用 SIGSEGV(信号 11)终止进程.无论您的构建设置如何,它都不会崩溃.

It means that the ld tool or one of its dependencies has a bug which results in an invalid memory access (segmentation fault) on which the operating system kills the process with SIGSEGV (signal 11). It should not crash regardless of your build setup.

您可能应该向您的 Linux 发行版供应商或直接向 ld 工具的供应商(通常是 GNU,以防您的 ld 工具来自 GNU binutils).

You should probably file a bug report for ld with your Linux distribution vendor or directly to the vendor of the ld tool (usually GNU in case your ld tool is from the GNU binutils).

这篇关于collect2:错误:ld 以信号 11 [Segmentation fault] 终止,核心转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-18 18:21