解决linux eclipse c++找不到符号或者~~~name a type的问题 && c++11

6 篇文章 0 订阅
3 篇文章 1 订阅

首先我的环境是:

centos 6.5

eclipse c++ 官网下载

gcc4.8.2



---

ok!

我的问题的出现是因为c++11的新的一些功能如:

std::function

std::bind

这些符号找不到。


---

下面是我的解决办法(注意往下看):

首先我的解决方式是参照:http://stackoverflow.com/questions/17457069/enabling-c11-in-eclipse-juno-kepler-luna-cdt这个帖子解决的,尊重原创。

如果你打不开这个链接,那么答案如下:

There's two things you have to do, first you need to setup your compiler, then you need to setup CDT's language processor. Since you didn't mention which compiler you're using, I'll assume it's GCC but the steps will be similar for other compilers. (Note that you need a compiler that supports C++11, of course.)

Setting up the compiler is fairly straightforward:

  1. Right click your project and click Properties
  2. Under C/C++ Build click Settings
  3. Under GCC C++ Compiler, click Miscellaneous
  4. In the Other Flags box, append "-std=c++11" to the list of tokens.
  5. Click Apply and OK

At this point you should be able to rebuild your project and get it to run. But CDT still may show errors for C++11 includes. Here's how you can resolve that:

  1. Right click your project and click Properties
  2. Under C/C++ General click "Preprocessor Include Paths, Macros"
  3. Select the Providers tab
  4. There should be an item in the list that says something like "GCC Built in Compiler Settings". Select this entry.
  5. Uncheck the "Use global provider..." option
  6. Under the list there's an box that says "Command to get compiler specs." Append "-std=c++0x" to this.
  7. Move the "GCC Built in Compiler Settings" provider at the top of the list using the 'Move Up' button on the right.
  8. Click Apply and then OK.
  9. Back in your Eclipse workspace, select the Project Menu, C/C++ Index, and click "Re-resolve unresolved includes."
这是上面链接的帖子的解决方案。



---

这个方法基本上解决了问题。但是对于我来说,只解决了一半问题,因为按照上面的方法修改后,问题依旧,怎么办呢,下来是我的方法。

---


alt+enter->c/c++ general->path and symbols->symbols tab->GNU C++

找到上图的位置,,注意这个位置是:项目-属性,你可以点击项目后,按alt+enter打开。

1、选择GNU C++,  

2、点击右边的add,

3、然后在name那个输入框里随便输入,你没有看错,随便输入后,点击ok确定,

4、然后点击下方的apply,会弹出一个对话框,选择yes。这个对话框估计就是目的所在。

5、然后删除刚刚添加的项。

6、重复4

7、Back in your Eclipse workspace, select the Project Menu, C/C++ Index, and click "Re-resolve unresolved includes."

上面我的方法是无意中发现的。

至少对我的问题是有效的。希望能解决你的问题。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值