I built a simple program in eclipse:
我在eclipse中构建了一个简单的程序:
#include <iostream>
using namespace std;
int main()
{
cout << "TEST" << endl;
return 0;
}
It worked in Visual Studio and CodeBlocks, but eclipse is acting weird. it says:
它在Visual Studio和CodeBlocks中工作,但是eclipse的表现却很奇怪。它说:
Unresolved inclusion: <iostream>
未包含:< iostream >
I read here: C++ - Unresolved inclusion: <iostream>
我在这里读到:c++ -未解析包含:
and here: Unresolved <iostream> in Eclipse, Ubuntu
这里是:在Eclipse中未解析的
and neither of them worked.
他们俩都不工作。
Here are screenshots of project properties
:
以下是项目属性的截图:
edit:
编辑:
I downloaded MinGW and now i have this under Settings
:
我下载了MinGW,现在我在下面设置:
How should i proceed? Maybe now i don't need #include <iostream>
because it's now included in the project?
我该如何继续?也许现在我不需要#include
I found iostream
under Includes
.
我发现iostream under include。
So i tried deleting #include <iostream>
, but when i try to run the program i get: Launch Failed. Binary not found.
error:
所以我尝试删除#include
Thanks
谢谢
edit:
编辑:
Seems like if i compile in some other program (say CodeBlocks) and create the exe
file, then eclipse
can run it. But it can't build its own exe
.
似乎如果我在其他程序(比如代码库锁)中编译并创建exe文件,那么eclipse就可以运行它。但它不能建立自己的exe。
Why?
为什么?
2 个解决方案
#1
0
This answer did not help me either. My issue was solved with the following steps:
这个答案对我也没有帮助。我的问题通过以下步骤得到解决:
You might try changing your source files from *.c to *.cpp. This will provoke gcc to think of the files as C++ and search the proper paths. Might need to make small modifications to the Makefile as well, like on the OBJ: line. Instead of:
您可以尝试从*修改源文件。c * . cpp。这将促使gcc将这些文件看作c++文件,并搜索适当的路径。可能还需要对Makefile进行小的修改,比如在OBJ: line上。而不是:
OBJS = YourFile.o
obj = YourFile.o
try
试一试
OBJS = YourFile.cpp
obj = YourFile.cpp
#2
-2
right click your project click properties goto C/C++ Build > settings click on Misc. under GCC C++ Compiler and the other flags code should have this after it -std=c++11 then go to Misc. under GCC C Compiler and add this to the other flags code -std=gnu11 apply save your project build your project and it should work
右键单击您的项目,单击properties goto C/ c++ Build >设置,单击Misc。在GCC c++编译器和其他标记代码后面应该有这个-std=c++11,然后转到Misc。在GCC C编译器下,将它添加到其他标志代码-std=gnu11中,应用save您的项目构建您的项目,它应该可以工作
#1
0
This answer did not help me either. My issue was solved with the following steps:
这个答案对我也没有帮助。我的问题通过以下步骤得到解决:
You might try changing your source files from *.c to *.cpp. This will provoke gcc to think of the files as C++ and search the proper paths. Might need to make small modifications to the Makefile as well, like on the OBJ: line. Instead of:
您可以尝试从*修改源文件。c * . cpp。这将促使gcc将这些文件看作c++文件,并搜索适当的路径。可能还需要对Makefile进行小的修改,比如在OBJ: line上。而不是:
OBJS = YourFile.o
obj = YourFile.o
try
试一试
OBJS = YourFile.cpp
obj = YourFile.cpp
#2
-2
right click your project click properties goto C/C++ Build > settings click on Misc. under GCC C++ Compiler and the other flags code should have this after it -std=c++11 then go to Misc. under GCC C Compiler and add this to the other flags code -std=gnu11 apply save your project build your project and it should work
右键单击您的项目,单击properties goto C/ c++ Build >设置,单击Misc。在GCC c++编译器和其他标记代码后面应该有这个-std=c++11,然后转到Misc。在GCC C编译器下,将它添加到其他标志代码-std=gnu11中,应用save您的项目构建您的项目,它应该可以工作