我下载了qt 5.1.1的源代码并成功构建了它。现在我正在尝试测试它并设置正确的路径变量。我在/usr/local/qt511/include 中获取了所有包含文件,在/usr/.../lib 中获取了所有包含文件,当我尝试使用此 cmd 使用 g++ 构建它时:
g++ -Wall -I/usr/local/qt511/include main.cpp -o main
它会抛出错误。 我注意到在 qt511 中的 include 目录中还有带有标题的附加目录。所以我的第一个问题这个选项 -I/usr/local/qt511/include 是否足以通知编译器所有 header ,尽管它们分配在子目录中?
此外,我尝试从教程中构建一个示例。很简单。 F.e 模拟时钟。它的主体中有#include
g++ -Wall -I/usr/local/qt511/include/QtGui main.cpp -o main
响应是:
In file included from main.cpp:41:0:
/usr/local/qt511/include/QtGui/QtGui:3:30 fatal error : QtGui/QtGuiDepends : No such file or directory. Compilation Terminated.
我检查了QtGui目录,有QtGuiDepends.... 我不知道发生了什么
提前感谢任何提示
最佳答案
经过几个漫长的夜晚......
好的,我在这些主题中找到了答案: Bash: Recursively adding subdirectories to the path 和 How to make g++ search for header files in a specific directory?
我为解决问题所做的事情是:
添加到我的 .bashrc (我使用 Ubuntu 12.04)
export CPLUS_INCLUDE_PATH=/pathtoincludedir
在我添加的第一个链接中使用这个好技巧。
现在我可以简单地编译我的qt程序
g++ -Wall main.cpp -o 文件名
希望这能帮助像我这样的其他初学者=)永远不要停止挖掘!
关于linux - 尽管路径正确,但 g++ 找不到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19147177/