G++不使用QT存储标题目录
作为C ++的初学者,我请您的帮助
,我必须与QT一起工作,因为我被提供了一些学校项目的源文件,但无法使用G ++(Mingw-w64)构建代码。 所有项目源文件和标头文件都在工作区文件夹中的各自文件夹中组织。添加到其中是G ++需要获取的QT的标题和源文件。
在其第三行中,我的main.cpp文件以``#include''来调用qapplication文件。反过来,此Qapplication要求使用其他子模块,例如“ #include< qtwidgets/qtwidgetsglobal.h>'。
我首先将此命令输入终端:
g++ -c main.cpp
显然导致了以下错误:
main.cpp:3:10: fatal error: QApplication: No such file or directory
3 | #include <QApplication>
^~~~~~~~~~~~~~
compilation terminated.
然后我尝试了以下错误:
g++ -c main.cpp -ID:/QT515/Tools/QtDesignStudio/qt5_design_studio_reduced_version/include/QtWidgets
并收到此错误:
D:\TUM_bureau\Cours\SS_2022\ARL\Group-D-master>g++ -c main.cpp -I D:/QT515/Tools/QtDesignStudio/qt5_design_studio_reduced_version/include/QtWidgets
In file included from D:/QT515/Tools/QtDesignStudio/qt5_design_studio_reduced_version/include/QtWidgets/QApplication:1,
from main.cpp:3:
D:/QT515/Tools/QtDesignStudio/qt5_design_studio_reduced_version/include/QtWidgets/qapplication.h:43:10: fatal error: QtWidgets/qtwidgetsglobal.h: No such file or directory
43 | #include <QtWidgets/qtwidgetsglobal.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
似乎编译器可以在调用main.cpp时一次找到标头文件的位置,但是然后,当另一个源文件由MAIN调用时,它会忘记这些标头的位置。更糟糕的是,此QTwidgetSglobal与Qapplication在同一文件夹中,因此找到它应该没有问题。
有人可以给我任何指导吗?
Being a beginner at c++ I kindly request your help
I have to work with Qt as I was provided a couple of source files for a school project, but can't manage to build the code with g++ (MinGw-w64).
All the project source files and header files are organized in their respective folders within a workspace folder. Added to that are the headers and source files for Qt that g++ needs to fetch.
In its third line, my main.cpp file calls for the QApplication file with '#include '. In turn, this QApplication calls for other submodules with for example '#include <QtWidgets/qtwidgetsglobal.h>'.
I first entered this command into the terminal:
g++ -c main.cpp
Which obviously led to the following error:
main.cpp:3:10: fatal error: QApplication: No such file or directory
3 | #include <QApplication>
^~~~~~~~~~~~~~
compilation terminated.
I then tried the following:
g++ -c main.cpp -ID:/QT515/Tools/QtDesignStudio/qt5_design_studio_reduced_version/include/QtWidgets
and got this error:
D:\TUM_bureau\Cours\SS_2022\ARL\Group-D-master>g++ -c main.cpp -I D:/QT515/Tools/QtDesignStudio/qt5_design_studio_reduced_version/include/QtWidgets
In file included from D:/QT515/Tools/QtDesignStudio/qt5_design_studio_reduced_version/include/QtWidgets/QApplication:1,
from main.cpp:3:
D:/QT515/Tools/QtDesignStudio/qt5_design_studio_reduced_version/include/QtWidgets/qapplication.h:43:10: fatal error: QtWidgets/qtwidgetsglobal.h: No such file or directory
43 | #include <QtWidgets/qtwidgetsglobal.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
It seems that the compiler can find the location of the header file once when it calls main.cpp, but then when another source file is called by the main it forgets where these headers are. Even worse, this qtwidgetsglobal is in the same folder as QApplication so it should have no problem finding it.
Could someone give me any direction please ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论