Qt Creator中找不到头(说:"没有这样的文件或目录")

Qt Creator中找不到头(说:"没有这样的文件或目录")

问题描述:

我怎么能告诉Qt Creator的2.4.1(基于Qt 4.7.4 32位)在哪里看的默认作为头文件?

How can I tell Qt Creator 2.4.1 (based on Qt 4.7.4 32-bit) where to look by default for header files?

当我在Qt Creator中打开一个C文件,并说

When I open a C file in Qt Creator and say

#include <stdio.h>

它强调该行并说

stdio.h: No such file or directory

我想告诉它来寻找我选择的目录标题;我该怎么做呢?

I would like to tell it to look for headers in a directory of my choice; how do I do this?

我想我也应该问:这是连的可能的?或者我必须创建一个完整的项目,每次我想编辑独立的C ++文件?

I guess I should also ask: Is this even possible? Or must I create an entire project every time I want to edit a standalone C++ file?

我发现自己经常碰到这样的问题。我可以重现它在我的机器上,现在还有(Mac OS)中。

I found myself often faced with this problem. I can reproduce it on my machine right now as well (Mac OS).

它看起来像QtCreator需要有一个项目,正确处理GCC路径分析(在上面的Qt的框架pathes)。结果
Qt使用找头的过程,它启动GCC(或你的编译器在Windows上)具有特殊的参数,使其输出pathes编译器在哪里找到它的头。 BUT ,要做到这一点,必须有相关的到你的文件的项目,因为它使用这个项目确定要使用的工具链,从而GCC的地方找到。

It looks like QtCreator needs to have a project to correctly handle GCC path analysis (on top of Qt frameworks pathes).
The process Qt uses to find the headers is that it launches GCC (or your compiler on Windows) with special arguments that make it output the pathes where the compiler finds its headers. BUT, to do that, it must have a project associated to your files, because it uses this project to determine what toolchain to use, thus where GCC is found.

因此​​,答案是这样的:创建一个项目,总是,使用语法analyzis结果
请注意,当你创建这个项目,可以定义它了Qt SDK,你会使用工具链的版本,否则语法控制单击将无法正常工作是非常重要的。

So the answer is this: create a project, always, to use the syntax analyzis.
Note that it is quite important that when you create this project, you define which version of the Qt SDK and the toolchain you'll use, otherwise the syntax control-click won't work.

您可能会发现虽然没有使用Qt SDK或使用造物主构建项目使用Qt工程文件的一些有趣的方法。看到一个答案在这里一个类似的问题: http://*.com/a/5817226/389405

You might find some interesting ways of using a Qt Project file although not using the Qt SDK or using Creator to build your project. See an answer to a similar question here: http://*.com/a/5817226/389405

请注意,我personnally使用这种方法,与简单地列出我的项目的所有子目录的.pro 文件,并与所有的键盘快捷键来构建禁用,使我只使用Qt Creator中作为一个编辑器。语法高亮/链接是真棒,exceptionnally快,远远比Eclipse的远快!

Note that I personnally use this method, with a .pro file that simply lists all the subdirectories of my project, and with all keyboard shortcuts to build disabled, so that I only use Qt Creator as an editor. The syntax highlighting/linking is awesome and exceptionnally quick, far, far quicker than Eclipse!

要做到这一点,只需在您的项目目录发布的qmake -Pro 。这将创建一个 [DIR]的.pro 文件,可以删除任何时候。

To do that, simply issue qmake -pro in the directory of your project. It will create a [DIR].pro file that you can remove any time.

我填一个bug一年前上在这里打扰我这个语法analyzis的一个方面:https://bugreports.qt-project.org/browse/QTCREATORBUG-4846 ,编译器我在法国,而不是使用英语输出其数据的原因17930。他们固定在code在2.4,但它可能是Unix的特定的(见问题的更多信息,评论),所以你可能会想测试是否该问题可以应用到你的情况。

I filled a bug a year ago on an aspect of this syntax analyzis that was bothering me here: https://bugreports.qt-project.org/browse/QTCREATORBUG-4846 , the reason beiing that the compiler I use output its data in French instead of English. They fixed the code in 2.4 but it might be Unix-specific (see the comments of the issue for more information) so you'll probably want to test if this issue can be applied to your case.

如果您的问题仍然存在,即使您的刊物创建项目后,请务必在qt-project.org把它指向的家伙!

If your issue continues even after creating a project for your edition, make sure to point it to the guys at qt-project.org !

否则,我看到的是修改QtCreator源$ C ​​$ C的唯一解决方案。您可以在自己的最后一个职位找到有关如何在这里贡献一些信息:http://labs.qt.nokia.com/2012/03/15/qt-creator-2-5-beta/ (和尝试,它支持C ++他们的新测试版的的lambda 的)。

Otherwise, the only solution I see is modifying the source code of QtCreator. You can find in their last post some information about how to contribute here: http://labs.qt.nokia.com/2012/03/15/qt-creator-2-5-beta/ (and try their new beta which supports C++ lambdas).