0

How can I fix the problem other computer the program can't start because libgcc_s_dw2-1.dll is missing from your computer? The computer compiled the program and the computer running the program are different.

As I am using CLion, it seems like I have to change the CMake file, but I couldn't get advice from many sites I have found. What should I add to my project?

I have looked at other question How can I install GCC runtime libraries with CMake?, but I have no idea what's going on in this answer.

user5876164
  • 471
  • 3
  • 15
  • 1
    Is there a libgcc_s_dw2-1.dll next to the executable you are running on the other computer? – rubenvb Feb 14 '19 at 12:38
  • @rubenvb I don't know, but probably yes. I don't own that computer. – user5876164 Feb 14 '19 at 12:39
  • @Blaze Probably not a duplicate, since CodeBlocks does not use CMake files.. – user5876164 Feb 14 '19 at 12:39
  • @user5876164 I think it's more of a MinGW or GCC issue that a CodeBlocks/CLion/CMake issue, but correct me if I'm wrong. The solution in the dupe is to statically link the libcc, so that sounds like it's worth a shot. – Blaze Feb 14 '19 at 12:41
  • 3
    @user5876164 CMake has nothing to do with this. You are distributing the compiled executable. You know what is on the other computer. If you don't, I don't think we can help you. – rubenvb Feb 14 '19 at 12:42
  • As described in the answer in the dupe you can either statically link or distribute the dlls with your executable. It's exactly a dublicate of https://stackoverflow.com/questions/12995166/how-can-i-install-gcc-runtime-libraries-with-cmake – Thomas Sablik Feb 14 '19 at 12:50
  • @ThomasSablik Then how do I statically link the dll? Please note that I couldn't understand none of the answers link given in this question. – user5876164 Feb 14 '19 at 12:54
  • Insert `CMAKE_EXE_LINKER_FLAGS=-static` into your cmake file – Thomas Sablik Feb 14 '19 at 12:54
  • @ThomasSablik he would also have to build MinGW statically to provide the static libraries. A difficult process for a beginner, not to mention licensing issues. – Michael Surette Feb 14 '19 at 12:59
  • @ThomasSablik adding `CMAKE_EXE_LINKER_FLAGS=-static` to cmake files gives an error. What should be the issue for this? – user5876164 Feb 14 '19 at 13:33
  • 1
    As @MichaelSurette said: for static linking you need static libraries. If you don't have them you need to build them. This means you need to build MinGW by yourself. Where is your problem with distributing the dlls? – Thomas Sablik Feb 14 '19 at 13:35

1 Answers1

3

You have compiled and linked a computer program on your computer and distributed it to another. You need to include all the linked in dll's that don't come with Windows.

Find the required dll in your MinGW install and provide it to your friend and have him place it with your executable. There may be others. If MinGW has an ldd utility, you can use it to see what dll's your program links to.

Michael Surette
  • 701
  • 1
  • 4
  • 12