Search code examples
c++buildcodeblockslibgcc

c++ program failed to run on another pc with libgcc error


I wrote some simple code in C++, and I built it and ran it on my laptop, and everything as working. When I tried to run the .exe file on my brother's laptop, it gave me this error The program can't start because libgcc_s_sjlj-1.dll is missing from your computer. Try reinstalling the program to fix this problem. Am I missing something that I should have added or something?

Note: I don't know if it matters or not, but I'm using Code::Blocks.

Thanks


Solution

  • It matters because you used Code::Blocks. If you don't know about it, you most probably used Code::Blocks with MinGW. Install it on that machine followed by a reboot may fix it.

    C++ programs need to have a runtime library -- you can think of it as needing .NET Framework to run C# or JRE to run Java programs. Visual C++ uses msvcrt (known as Visual C++ Runtime). Many installations of Windows seem to come with msvcrt by default which may explain why people using MSVC is less likely to run into issues like this.

    If you statically link the CRT (C Run Time) you can lift the requirements of the clients having to have the DLL files installed, at the expense of having a larger .exe file.

    A relevant SO answer: The program can't start because libgcc_s_dw2-1.dll is missing