简体   繁体   English

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

[英]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. 我最近决定学习C / C ++,以准备在几个月后学习的编码课程,因此我下载并安装了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!" 当我浏览HelloWorld项目的教程时,遇到一个问题,即使代码编译得很好,控制台也不会输出“ 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. 当我运行调试器时,它说终止了,退出值为-1073741515,其后是我的目录“ C:\\ Users \\ Example \\ workspace \\ HelloWorld \\ Debug \\ HelloWorld.exe”,然后是日期和时间。

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. 我安装了MinGW,并将Eclipse的路径设置为C:\\ MinGW \\ bin,它位于我的目录中,并且检查以确保自己的偏好设置正确,因为在此之前,我在PATH中找不到一些“程序g ++” ”和“在PATH中找不到程序gcc”,当我更改环境变量时,这些错误已修复。

When I continued to follow the tutorial, along with the HelloWorld.cpp which contained this code 当我继续阅读本教程以及包含此代码的HelloWorld.cpp时

#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 接下来,他们告诉我写一个包含以下代码的main.cpp

#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: 最后,他们告诉我创建一个makefile来帮助构建和运行包含以下代码的项目:

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!" 该程序应该做的只是打印“ 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. 在控制台中操作了五次,但并没有,只是返回了“终止的退出值:-1073741515”,我对此感到非常困惑。 Can someone please help me? 有人可以帮帮我吗? Thank you all. 谢谢你们。

I have some experience with Eclipse C/C++ 我对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. 我建议的第一件事是,您通过启动一个新项目来进行测试,然后单击“新的hello world”选项,而不是应该设置所有项目的“空项目”。 - When you have done this you should be able to run the program using the buttons in Eclipse. -完成此操作后,您应该能够使用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. 如果它不起作用,则可能是有问题,很可能是Eclipse找不到编译器。 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. 以我的经验来看,Eclipse确实很棒,但是有太多选择可能令人生畏,而且我知道我没有充分利用它的潜力。

If you are really stuck try using PELLES instead of Eclipse - in my experience this is alot easier to get started with. 如果您真的很困惑,请尝试使用PELLES而不是Eclipse-以我的经验,这很容易上手。

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. 可以肯定的是,将您的MinGW Binaries文件夹的完整路径添加到Windows路径,然后重新启动。 (Cygwin binaries folder (C:\\Cygwin64\\bin, on my system) for Cygwin users). (Cygwin用户的Cygwin二进制文件夹(在我的系统上为C:\\ Cygwin64 \\ bin))。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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