1

I wrote a c++-program including <iostream> to use std::cout and std::cin. I compiled it with the g++ compiler (GNU compiler collection) on Windows 10 using MinGW. When I run the program with the run-terminal of MinGW it works but when I try to run it with cmd.exe or open it in Windows Explorer I get this Error:

"The program cannot be run because libstdc++-6.dll is missing. Please reinstall the program to solve the problem."

Because I didn´t install my program, I tried to install libstdc++-6.dll. I downloaded the file in zip-format but I don´t know where to unpack. Has this file to be in system32? Do I have another problem? Can anyone help me to solve it? I already read a simliar question and its answers but -static-libgcc -static-libstdc++ didn´t work.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Aemyl
  • 1,501
  • 1
  • 19
  • 34
  • 1
    You probably have a path problem. Can you post for us what you get when type: echo $PATH in your MinGW run terminal and what you get when you type: echo %PATH% in cmd.exe? – David Mar 16 '16 at 23:35
  • 1
    Possible duplicate of [libstdc++-6.dll not found](http://stackoverflow.com/questions/6404636/libstdc-6-dll-not-found) – user4581301 Mar 16 '16 at 23:43
  • in MinGW I get the result $PATH and in cmd.exe I get the result "The command C:\Python27\ is written wrong or cannot be found." I also develop Python-programs to explain this. – Aemyl Mar 17 '16 at 12:33
  • @david yes, was a path problem. In the MinGW path (where the g++.exe is) are some dll-files. I just need to copy three of them (libstdc++-6.dll, libgcc.dll and libwinp-thread.dll) and insert them into the folder where my C++ programms are. Now they run, thank you. – Aemyl Sep 20 '16 at 14:23

2 Answers2

2

This is a repetition of this question libstdc++-6.dll not found according to @kerrek-sb do this

If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgcc and -static-libstdc++ to link the C and C++ standard libraries statically and thus remove the need to carry around any separate copies of those. Version management of libraries is a pain in Windows, so I've found this approach the quickest and cleanest solution to creating Windows binaries.

Community
  • 1
  • 1
Dendi Suhubdy
  • 2,877
  • 3
  • 19
  • 20
  • I already read this question and the answers but linking the libraries with the -static options didn´t work :( – Aemyl Mar 17 '16 at 12:26
0

You might want to compile your code with g++ and the options -static-libgcc and -static-libstdc++ so to link the C and C++ standard libraries statically. As a result you don't have to install libraries in your Windows path and you can carry around the executable on other systems.

Patrick Trentin
  • 7,126
  • 3
  • 23
  • 40
  • I read this answer to a similar question but as I tried to compile with this options it still didn´t work – Aemyl Mar 17 '16 at 12:28
  • can you confirm with `strings MY.EXE | grep -i \.dll$` or `DependencyWalker` that the library doesn't show up to be linked dynamically? ---------- ETA: try using this, might be more reliable https://github.com/gsauthof/pe-util – Patrick Trentin Mar 17 '16 at 12:33
  • the commands grep and DependencyWalker cannot be found. Did I missunderstand you? the command strings works and prints a very long list of sth (module names?) in cmd. – Aemyl Mar 17 '16 at 12:43
  • DependencyWalker is a third party application http://www.dependencywalker.com/ . Or you can search for *.dll files in the output of strings. – Patrick Trentin Mar 17 '16 at 12:45