Eclipse C++: Symbol 'std' could not be res

2020-02-02 08:44发布

I am getting this error in the TestExecute.cpp -

"Symbol 'std' could not be resolved"

CODE

#include <iostream>
using namespace std;

I just created a executable project in Eclipse (in Windows 7) as shown below. It seems like I am selecting a toolchain that is not supported. Is it so? I have installed Cygwin and it is available in preferences.

EDIT: Based on @RobertoWilko comment, removing the line "using namespace std; " removed the error. But the binary is not created. "Launch Failed. Binary not found". How to correct this?

enter image description here

enter image description here

enter image description here

enter image description here

9条回答
Lonely孤独者°
2楼-- · 2020-02-02 08:58

I do not know whether you have solved this problem but I want to post my solution for those might ran into the same problem.

  1. First, make sure that you have the "Includes" folder in your Project Explorer. If you do not have it, go to second step. If you have it, go to third step.

  2. Second, Window -> Preferences-> C/C++- > Build >Environment: Create two environment variables:

    a) Name: C_INCLUDE_PATH Value: /usr/include

    b) Name: CPLUS_INCLUDE_PATH Value: /usr/include/c++

Go to Cygwin/usr/include/, if you cannot find folder "c++", copy it from \cygwin\lib\gcc\i686-pc-cygwin\X.X.X\include and Then restart your Eclipse.

  1. Third, Right Click your project in Project Explorer -> Properties -> C/C++ General -> Paths and Symbols -> Includes -> Languages:GNU C++ If you can find some C++ folders in the "Include directories" then click Apply and OK. Change a bit your codes, and save it.

You will find there will be not symbol could not be resolved problems.

I documented my solution, hoping someone might get benefits.

查看更多
狗以群分
3楼-- · 2020-02-02 09:02

For MinGW this worked for me:

  • Right click project, select Properties
  • Go to C/C++ General - Paths and Symbols - Includes - GNU C++ - Include directories
  • Select Add...
  • Select Variables...
  • Select MINGW_HOME and click OK
  • Click Apply and OK

You should now see several MinGW paths in Includes in your project explorer.
The errors may not disappear instantly, you may need to refresh/build your project.


If you are using Cygwin, there could be an equivalent variable present.

查看更多
Explosion°爆炸
4楼-- · 2020-02-02 09:02

The problem you are reporting seems to me caused by the following:

  1. you are trying to compile C code and the source file has .cpp extension
  2. you are trying to compile C++ code and the source file has .c extension

In such situation Eclipse cannot recognize the proper compiler to use.

查看更多
来,给爷笑一个
5楼-- · 2020-02-02 09:07

Try out this step: https://www.eclipse.org/forums/index.php/t/636348/

Go to

Project -> Properties -> C/C++ General -> Preprocessor Include Paths, Macros, etc. -> Providers

  • Activate CDT GCC Built-in Compiler Settings
  • Deactivate Use global provider shared between projects
  • Add the command line argument -std=c++11.

example

查看更多
Summer. ? 凉城
6楼-- · 2020-02-02 09:07

I was having this problem using Eclipse Neon on Kubuntu with a 16.04 kernel, I had to change my #include <stdlib.h> to #include <cstdlib> this made the std namespace "visible" to Eclipse and removed the error.

查看更多
唯我独甜
7楼-- · 2020-02-02 09:09

You can rewrite the code likes this:

#include<iostream>
#include<stdio.h>

using namespace std;
查看更多
登录 后发表回答