CMake build failed. Undefined references in bundled MinGW (crtexe.c)

Windows 10 - Clion 2022.2.4 - MinGW W64 9.0

I am having trouble building my application using the bundled MinGW toolset. My build is failing due to the following issues:

  • ...x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_initcharmax[.refptr.mingw_initcharmax]+0x0): undefined reference to `mingw_initcharmax'
  • ...x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltssuo_force[.refptr.mingw_initltssuo_force]+0x0): undefined reference to `mingw_initltssuo_force'
  • ...x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdyn_force[.refptr.mingw_initltsdyn_force]+0x0): undefined reference to `mingw_initltsdyn_force'
  • ...x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdrot_force[.refptr.mingw_initltsdrot_force]+0x0): undefined reference to `mingw_initltsdrot_force'
  • x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_app_type[.refptr.mingw_app_type]+0x0): undefined reference to `mingw_app_type'

I was unable to find any results in regards to these undefined references in the context of CLion.

0
2 comments

Hello!

Does the issue happen in a default "Hello, World!" project (`File | New Project` > `C++ Executable` > `Create`)?

0

No, it builds just fine in a brand new project. When I use select my local toolset (C:\msys64\mingw64) I don't get this issue. I am able to build successfully if I use the following configuration:

Builds, Execution, Deployment > Toolchains:

Builds, Execution, Deployment > CMake:

0

Please sign in to leave a comment.