G++不使用QT存储标题目录

发布于 2025-02-06 06:48:12 字数 1477 浏览 1 评论 0原文

作为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文