Search code examples
c++windowsmakefilemsys2

Compiling Makefile in Windows runs into "collect2: fatal" error


I am trying to remake the run and infer binaries from this open source repository in GitHub: files here. The Makefile is the one creating the run and infer files.

I am currently on Windows 11, with msys2. I have:

  • make-4.3.3 installed
  • gcc-11.3.0, and also installed.
  • and binutils-2.37-5 installed

Currently, when I run make (when standing in the src directory) with msys2, I get the following error:

$ make
g++ obtm.o ibtm.o main.o -o run
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
make: *** [Makefile:9: run] Error 1

If you check Makefile:L9, that line has the following (copyng lines8-9 below):

run:obtm.o ibtm.o main.o
    $(CC) $^ -o $@

Running the make gives me a 0KB "run.exe" file, and a ld.exe.stackdump file. I am copying the content of the latter below:

Exception: STATUS_ACCESS_VIOLATION at rip=0010042CA94
rax=0000000000000000 rbx=0000000100597700 rcx=0000000100597700
rdx=0000000800094010 rsi=0000000800870140 rdi=00000008008D5640
r8 =000000080087013A r9 =0000000000000002 r10=FEFEFEFEFEFEFEFF
r11=000000010042C9DF r12=0000000000000000 r13=000000010054170C
r14=0000000800094010 r15=00000000FFFFC698
rbp=0000000100514E80 rsp=00000000FFFFC570
program=C:\msys64\usr\x86_64-pc-msys\bin\ld.exe, pid 2480, thread main
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame        Function    Args
00100514E80  0010042CA94 (008008D2000, 008000F9CC8, 008008700F0, 00000000000)
00000000000  00100423245 (008000F9CC8, 008000937B0, 008000DC968, 00100597700)
00800870140  0010042BAD2 (00800086220, 008000C00F8, 0010045202F, 00000000001)
0080087013A  0010042BE7A (000FFFFC890, 00800084718, 001005374E0, 00180374818)
001005981A4  001004240D7 (0010052B6E2, 008000007D0, 0010044AFF9, 00430B3954B)
00800078138  00100413CA8 (00430B39600, 00180234000, 001802B5BF3, 001802B5BED)
0010052B6E2  00100512BEC (000FFFFCAA0, 00000000000, 00000000000, 00180156FA8)
000FFFFCD30  00180049B91 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0  00180047716 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0  001800477C4 (00000000000, 00000000000, 00000000000, 00000000000)
End of stack trace

I did try to check similar topics (like this collect2: fatal error: ld terminated with signal 11 [Segmentation fault] and compiler gives error ld terminated with signal 11 to no avail).


Solution

  • Just in case someone else is in the same debacle--the folders have some *.o files. I just had to delete those, alongside the older run and infer, simply run make while standing in that folder, and it worked!