Eclipse CDT C++ 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8015928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:17:54  来源:igfitidea点击:

Eclipse CDT C++ error

c++eclipseeclipse-cdt

提问by Phil

I have just installed Eclipse CDT on my machine for developping C++ applications.

我刚刚在我的机器上安装了 Eclipse CDT,用于开发 C++ 应用程序。

I have created a new C++ project. I have copied a cpp file.

我创建了一个新的 C++ 项目。我复制了一个cpp文件。

When I click the build button, the project compile without errors.

当我单击构建按钮时,项目编译没有错误。

However, I have a problem. The problem is that Eclipse tell me that there is many errors. For example Eclipse show that "using namespace std" is an error or that "#include " is an error.

但是,我有一个问题。问题是Eclipse告诉我有很多错误。例如,Eclipse 显示“使用命名空间 std”是一个错误,或者“#include”是一个错误。

I don't know what is the problem with Eclipse because my file compile properly when i click the "build" button.

我不知道 Eclipse 有什么问题,因为当我单击“构建”按钮时我的文件编译正确。

Is there some settings that I did not set properly?

是否有一些我没有正确设置的设置?

Thanks!

谢谢!

回答by tune2fs

You need to add the paths to the std libraries to your project in eclipse. It seems that somehow eclipse did not find your std library. You need to add the path to your gcc include under:

您需要在 eclipse 中将 std 库的路径添加到您的项目中。似乎 eclipse 以某种方式没有找到您的 std 库。您需要将路径添加到您的 gcc 包括在:

properties->C/C++ General->Paths and Symbols->Includes->GNU C and GNU C++

属性->C/C++ General->Paths and Symbols->Includes->GNU C and GNU C++

The paths GCC/G++ uses can be found by the commands in this answer to "Where does gcc look for C and C++ header files?".

GCC/G++ 使用的路径可以通过“gcc 在哪里查找 C 和 C++ 头文件?”的答案中的命令找到。.

回答by NickyP

Requires a restart of eclipse to be active.

需要重新启动 eclipse 才能处于活动状态。

回答by Alexey Godin

Install the GNU C++ Compiler g++, using the command:

安装 GNU C++ Compiler g++,使用以下命令:

sudo apt-get install g++

回答by Umar

In my case (I am using TDM GCC installed on a non-standard location on Windows), I had to add the Path variable to the project. I did it by Project->Properties->C/C++ build->build variables. The value to the Path variables are auto read when one clicks on add and then select Path from the drop down list. Once the Path variable is added the C/C++ index needs to be rebuild.

就我而言(我使用的是安装在 Windows 非标准位置上的 TDM GCC),我必须将 Path 变量添加到项目中。我是通过 Project->Properties->C/C++ build->build variables 完成的。单击“添加”然后从下拉列表中选择“路径”时,将自动读取路径变量的值。添加 Path 变量后,需要重建 C/C++ 索引。