Skip to content

[Bug]: Linking error with MinGW-w64 15.2.0 on Windows: undefined reference to __imp__Exit and __imp_quick_exit #4952

@DongDongBan

Description

@DongDongBan

Describe the issue

I tried compiling the example using MinGW 15.2.0, but encountered the following errors:

[ 20%] Built target gtest
[ 40%] Built target gtest_main
[ 50%] Linking CXX executable hello_test.exe
F:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: F:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-ucrt_exit_wrappers.o):ucrt_exit_wrappers.c:(.rdata$.refptr.__imp__Exit[.refptr.__imp__Exit]+0x0): undefined reference to `__imp__Exit'
F:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: F:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-ucrt_exit_wrappers.o):ucrt_exit_wrappers.c:(.rdata$.refptr.__imp_quick_exit[.refptr.__imp_quick_exit]+0x0): undefined reference to `__imp_quick_exit'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [CMakeFiles\hello_test.dir\build.make:104: hello_test.exe] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:156: CMakeFiles/hello_test.dir/all] Error 2
mingw32-make: *** [Makefile:145: all] Error 2

Steps to reproduce the problem

Set up a minimal CMake project following GoogleTest's official Quick Start: Building with CMake
Use FetchContent to pull GoogleTest v1.17.0
Configure with CMake and MinGW Makefiles
Build using cmake --build build

What version of GoogleTest are you using?

  1. Set up a minimal CMake project following GoogleTest's official docs Quick Start: Building with CMake
  2. Use FetchContent to pull GoogleTest v1.17.0
  3. Configure with CMake and MinGW Makefiles
  4. Build using cmake --build build

What operating system and version are you using?

  • OS: Windows 10
  • GoogleTest version: v1.17.0 & main branch

What compiler and version are you using?

  • MinGW-w64 version: 15.2.0

What build system are you using?

  • Build system: CMake: 4.2.3

Additional context

Does this issue relate to whether the downloaded MinGW-w64 uses MSVCRT or UCRT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions