Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

During startup program exited with code 0xc0000139 [duplicate]

UPDATE:

This turned out to be a compiler issue (I was using MinGW) so a workaround is switching to another compiler (in this case Cygwin).


The (original) question

I'm a student starting to learn C++ by myself and I have come across a problem when trying to work with string

This is my test code (the one that isn't working)

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string myString;

    cin >> myString;
    cout << myString;

    return(0);
}

When I tried to run it, the program just ended and exited before I can input anything, and this is the result when I tried to run from gdb

(gdb) run
Starting program: C:\Users\DANIEL~1\AppData\Local\Temp\sandbox.exe
[New Thread 15036.0x31bc]
[New Thread 15036.0x2db4]
[New Thread 15036.0x2628]
[New Thread 15036.0x2280]
During startup program exited with code 0xc0000139.
(gdb)

When I tried to make the file and run it from cmd

g++ sandbox_string.cpp -o sandbox_string

(I added the _string to separate from the _int makefile, the program is still the same)

I got this error: Entry point not found

After a trip round Google I believe that this problem is related to missing DLLs. How can I know what dll(s) I'm missing and is there a way to make sure I have every dlls ?

There are some points I would like to mention:

• I'm acknowledged that this may be a duplicate to Why are all my C++ programs exiting with 0xc0000139?, but that provided no solution other than downgrading GCC. I tried that and it didn't work. Also in that question someone mentioned about missing DLLs, but provided no further solution.

• If I tried to cin an integer for example:

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int myString;
    cin >> myString;
    cout << myString;
    return(0);
}

It works fine, I can input and the program would output then exit normally:

(gdb) run
Starting program: C:\Users\DANIEL~1\AppData\Local\Temp\sandbox.exe
[New Thread 9120.0x35ac]
[New Thread 9120.0x2c4c]
[New Thread 9120.0x390c]
[New Thread 9120.0x32c0]
7
7[Inferior 1 (process 9120) exited normally]
(gdb)

• My compiler is MinGW, this is my MinGW installer screenshot with (hopefully) every details you need MinGW Installer

• I'm using Atom - a text editor, with a plugin to compile and run C++ code (called "gpp-compiler") because I find it comfortable to stick with one text editor instead of using IDEs, but, if you think there's something else I should be using, please let me know.

• I'm not new to programming but I'm (very) new to C++ so please pardon me if there is any silly mistake, also this also means that I greatly prefer simple answer/solution if possible. But I will have no problem with complicated answer that's accompanied by a proper explanation.

Thanks

like image 579
Daniel D. Avatar asked Jan 25 '17 09:01

Daniel D.


1 Answers

The code seems to have no errors. but as it mentioned above this has been a compiler issue so switching to Cygwin from MinGW has solved the error.

The error code 0xc0000139 appears when mis-configured, important files gone missing or damaged. so switching in to a totally different compiler has solved the problem.

hope this will help to improve this questions value @Daniel D.

like image 104
Tharusha Avatar answered Sep 19 '22 14:09

Tharusha