-2

I'm trying to write to a file in C++, however as soon as I run my .exe file, I get the following error

"The procedure entry point __gxx_personality_v0 could not be located in the dynamic link library C:/Users..."

Here is my code

#include <iostream>
#include <fstream>

using namespace std;

int main(int argc, char *argv[])
{
    ofstream outfile ("test.txt");
    outfile << "Hello World\n"; // error happens here

    return 0;
}
Memhir_Yasue
  • 135
  • 1
  • 2
  • 10

2 Answers2

1

I managed to fix the problem by copying libstdc++-6.dll from C:\MinGW\bin into the directory of my project!

Memhir_Yasue
  • 135
  • 1
  • 2
  • 10
  • 3
    The alternative (and perhaps better way) would be to have added `C:\MinGW\bin` to your `PATH`. – john Mar 03 '19 at 10:06
  • You should also look at "dynamic link library C:/Users...". It could be a different installation of a different version of gcc. If so, remove it, or at least remove it from your PATH. – n. m. could be an AI Mar 03 '19 at 14:38
0

try this code

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
int main()
{
ofstream outfile;
outfile.open("text.txt")//opening the file
outfile<<"Hello world";
outfile.close();//closing the file
return 0;
}

whenever we are dealing with files, there should be opening the file and closing the file. For this program , the arguments inside the main function is not needed.