0

I am working in C++ for the first time and running into issues compiling multiple files. The issue appears to be related to the compiler being unable to find the libstdc++-6.dll file even though it is present in the minGW bin directory which is linked to in PATH. I am looking for help identifying why.

I wrote a basic main function that has both cout and cin, which compiles and runs as expected. However, when I add an additional basic class header file and an implementation file as well as add #include "className.h" at the top of the file with the main function, it behaves badly. When I Run Build Task, it builds an exe, but does not call either the cout or cin. If I then run the .exe on the external command prompt I get the following error:

enter image description here

I found several SO threads where this problem was solved by moving the libstdc++-6.dll into the directory containing the .exe. I copied and pasted the file from the minGW bin directory and that works. However, I would expect the compiler to find this file by itself and am wondering if there is some obvious reason why it would not find it.

I have several peers who followed the exact steps I did and their systems are picking up this file, so it seems it must be something that is misconfigured on mine. The .h and .cpp files I added have been thoroughly tested on other systems and are not the problem.

(I am using a PC with a windows 10 operating system, minGW 8.0.0, and VSCode 1.49.3, the last two were freshly installed today)

Saralyn
  • 303
  • 2
  • 4
  • 9
  • Try to search answer on SO typing the _ZNSt7_cxx1112... There is a ton of exact such questions on SO. – 273K Oct 03 '20 at 21:36
  • I have which is how I found the dll that was missing and was able to test if adding it fixed the issue. The other SO threads I have seen on this ask the user to add the dll. I want to know if there's a way I can run these *without* adding it in the directory every time. – Saralyn Oct 03 '20 at 21:42
  • Look at @Saralyn' answer, it's correct. The same answers are in the similar questions. – 273K Oct 04 '20 at 00:18

2 Answers2

1

The reason this was happening to me was because I had another software installed that was also using the libstdc++-6.dll file. This software has a shorter path to the file than mine so it was getting picked up instead.

The steps I took to fix this were:

  1. Use search on the file explorer to find all the places where this file exists.
  2. Move the other files to location with a longer path name.
Saralyn
  • 303
  • 2
  • 4
  • 9
  • Thanks for this answer, this is exactly what was happening to me. I typed `where libstdc++-6.dll` into Command Prompt to find out where the conflicting path was coming from. – Chris Jul 28 '23 at 15:45
-2

change from this #include <iostream> to this #include <bits/stdc++.h> this worked for me I am using VS Code with Mingw compiler and it fixed libstdc++-6.dll error.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
  • Please read this: [Why should I not #include ?](https://stackoverflow.com/q/31816095/10871073) Then consider editing and improving your answer. – Adrian Mole Sep 29 '21 at 14:11