Search code examples
c++cmakeclion

The exe package CLion created cannot be ran


When I try to run the exe package that CLion created, I got an error: libgcc_s_dw2-1.dll not found.

Does anyone know how to fix this?


Solution

  • If you are using MingW to compile C++ code on Windows, you may like to add the option -static-libstdc++ to link the C++ standard libraries statically. What exactly I mean is following:

    • For instance adding set(CMAKE_EXE_LINKER_FLAGS "-static") to your cmake file may fix it.

    Additionally please also make sure you have set the environment variable correctly for MinGW in your Windows environment variable section. What exactly I mean is following:

    • C:\MinGW\bin to your system PATH variable