Eclipse没有找到std c ++库 [英] Eclipse not finding std c++ libraries

查看:202
本文介绍了Eclipse没有找到std c ++库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台带有mingw的Windows8机器安装在c:\mingw
中,Eclipse确实成功地编译了程序,但是它会考虑到行中包含编译时的错误。 Eclipse没有找到库本身。



当我使用CDT组件安装在eclipse中构建一个项目时,它会在每个#include和每行上使用一个对象显示错误



示例:

  #include< iostream> 
使用命名空间std;

int main(){
cout<<< hello\\\
;
}

上面的代码显示了include,using和cout的错误, <线。
我可以通过点击:
project-> properties C ++ / General Preprocessor包含
,然后在提供者选项卡上,我可以检查CDT构建输出解析器并修复错误如下面第一个答案所述,我正在检查。但这只适用于该项目。我每次都要这样做。如何让eclipse简单地接受标准的C ++每个时间我建立一个新的项目,而不重新配置每个项目?



我已经能够通过进入项目设置和添加目录:



c:/ bin / mingw / lib / gcc / include
...



使用对象在线上留下错误。

  #include< iostream> 
#include< string>
#include< regex>
使用命名空间std;

int main(){
string s =这是一个测试。
regex e(est);
smatch m;

与正则表达式的行仍显示错误:无法解析正则表达式
即使代码编译和正则表达式包含被识别。



此外,在运行安装了Mingw的Windows 8.1的另一台机器上,eclipse将无法调试。有没有关于如何将Eclipse CDT连接到库的文档?

解决方案

虽然您显然从gcc中成功编译了代码, Eclipse,Eclipse有自己的内置C ++解析器,您需要单独让它知道您正在使用C ++ 11。



添加 CDT GCC内置编译器设置下的项目属性 - >中的-std = c ++ 11 C / C ++一般 - >预处理程序包含路径,编译器规格应与此类似:

  $ {COMMAND} -E -P -v -dD $ {INPUTS} -std = c ++ 11 






更新。请阅读设置包含C / C ++索引器的路径和宏 了解CDT如何自动发现包含路径和支持的工具链的预处理器符号(也称为扫描仪发现)适用于您。



要点是CDT使用语言设置提供程序来查找包含路径和预处理符号。而语言设置提供者可以在项目属性页面预处理器包含路径,宏等中进行配置。



一旦你有了正确的设置,你可以使它们成为一个模板工作区,只需将模板工作区复制到新的项目中,或者设置一个只设置相关设置的脚本。另请参阅:为所有Eclipse工作区设置首选项


I have a Windows8 machine with mingw installed in c:\mingw Eclipse does successfully compile programs, but it considers lines to contain errors that are fine when compiled. Eclipse is not finding the libraries itself.

When I first build a project in eclipse with the CDT components install, it shows errors on every #include and every line using an object.

Example:

#include <iostream>
using namespace std;

int main() {
  cout << "hello\n";
}

The above code shows errors on the include, the using and the cout << line. I can get rid of the errors by clicking: project->properties C++/General Preprocessor Include Then on the providers tab, I can check off "CDT Build output parser" and fix the mistakes as described by the first answer below, which I am upchecking. But this only works for the project. I have to do this every time. How can I get eclipse to simply accept standard C++ EVERY TIME I build a new project without reconfiguring each project?

I have been able to stop errors on the includes by going into project settings and adding the directories:

c:/bin/mingw/lib/gcc/include ...

That leaves the errors on lines using the objects.

#include <iostream>
#include <string>
#include <regex>
using namespace std;

int main() {
    string s = "this is a test.";
    regex e("est");
    smatch m;

The line with regex still shows an error: "type regex could not be resolved" even though the code compiles and the regex include is recognized.

Additionally, on a different machine running windows 8.1 with Mingw installed, eclipse will not debug. Is there some document on how to connect Eclipse CDT to the library?

解决方案

While you obviously successfully compile the code with gcc from within Eclipse, Eclipse has its own built-in C++ parser and you need to separately let it know that you are using C++11.

Add the -std=c++11 option to the CDT GCC Builtin Compiler Settings under Project propierties -> C/C++ General -> Preprocessor Include Paths, the compiler specs should look similar to this:

${COMMAND} -E -P -v -dD ${INPUTS} -std=c++11 


UPDATE. Please read Setting Up Include Paths and Macros for C/C++ Indexer to understand how CDT automatic discovery of include paths and preprocessor symbols (aka Scanner Discovery) for supported tool chains is applicable to you.

The gist is that the CDT uses the Language Settings Providers to find include paths and preprocessor symbols. And Language Settings Providers can be configured on project properties page "Preprocessor Include Paths, Macros, etc."

Once you have proper settings you can make them a template workspace and just copy the template workspace over for your new projects, or alternatively have a script that will set up just the relevant settings. Also see: Setting preferences for all Eclipse workspaces.

这篇关于Eclipse没有找到std c ++库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆