I attempted to set up my environment for C++ development and follow the hands-on practice. However, when running a simple program that prints "Hello, world," I encountered the following output: "Segmentation fault." While debugging the code, it seems that the problem lies with the "libstdc++-6.dll" file. However, I'm not sure how to resolve this issue, and I'm also uncertain if it's a common problem. Can someone assist me?
I'm using Windows 11.
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}
Prompt
$ g++ hello.cpp -o hello
$ ./hello
Segmentation fault
I had the exact same problem, caused by another dll file on my path with the name libstdc++-6.dll. For me the it was because of the Julia programming language. When using Visual Studio Code, you can see what files are loaded, in my case:
Loaded 'C:\Users\xxxx\AppData\Local\Programs\Julia-1.8.2\bin\libstdc++-6.dll'. Symbols loaded.
Basically, make sure to check your path ;) Especially for other programming languages (or maybe other older versions of your C++ compiler).