简体   繁体   中英

Eclipse- C/C++ <terminated, exit value: -1073741515>

I recently decided to learn C/C++ in preparation for a coding class I will take in a few months so I downloaded and installed Eclipse. When I was going through the tutorials for the HelloWorld project, I ran into a problem where even though the code compiled perfectly fine, the console would not output "HelloWorld!" When I ran the debugger, it said that it was terminated and that the exit value was -1073741515 followed by my directory "C:\\Users\\Example\\workspace\\HelloWorld\\Debug\\HelloWorld.exe" followed by the date and time.

I installed MinGW and I set my path for eclipse to C:\\MinGW\\bin which is where it is in my directory and I checked to make sure my preferences were right because prior to this I was having some "program g++ not found in PATH" and "program gcc not found in PATH" These errors were fixed when I changed the environment variables.

When I continued to follow the tutorial, along with the HelloWorld.cpp which contained this code

#include <iostream>
using namespace std;

int main() {
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}

Next, they told me to write a main.cpp which contained this code

#include <iostream>
using namespace std;

int main() {
    // Say Helloworld five times
    for (int index = 0; index < 5; ++index)
        cout << "HellowWorld!" << endl;
    char input = 'i';
    cout << "To exit, press 'm' then the 'Enter' key." << endl;
    cin >> input;
    while(input != 'm') {
        cout << "You just entered '" << input << "'. "
             << "You need to enter 'm' to exit." << endl;
        cin >> input;
    }
    cout << "Thank you. Exiting." << endl;
    return 0;

}

Finally, they told me to create a makefile to help build and run my project which contained this code:

all: hello.exe

clean: 
    rm main.o hello.exe

hello.exe: main.o
    g++ -g -o hello main.o

main.o:
    g++ -c -g main.cpp

What this program should be doing is just printing out "HelloWorld!" five times in the console, but it is not and is just returning the "terminated, exit value: -1073741515" I'm really confused as to why this is. Can someone please help me? Thank you all.

I have some experience with Eclipse C/C++

The first thing that I suggest is that you do a test by starting a new project and then click on the 'new hello world' option rather than 'empty project' that should set up all of your project. - When you have done this you should be able to run the program using the buttons in Eclipse.

If it works you are done - you can modify the program to whatever you wish and everything is made for ou.

If it does not work you have an issues, most likely with Eclipse not finding the compiler. You may be able to tell this when you start a new project as it will show the compilers that it has found on the right hand side of a start project window.

Hope this helps. In my experience Eclipse is really great, but has so many options it can be a little daunting and I know I don't use all the potential it has.

If you are really stuck try using PELLES instead of Eclipse - in my experience this is alot easier to get started with.

Your path settings may not be carrying through to your toolchain. To be sure, add the full path to your MinGW binaries folder to your Windows path and restart. (Cygwin binaries folder (C:\\Cygwin64\\bin, on my system) for Cygwin users).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM