简体   繁体   English

使用经典终端和gcc / g ++编译QT Creator项目

[英]Compilation QT Creator project using classic terminal and gcc/g++

I'm tired searching in internet. 我在互联网上搜索累了。 I created a klient-serwer program, which shut down computer just by their IP's on specific port.I made whole thing in C, everything works perfectly, i'm compiling my project using gcc with -Wall option and I've got a clear results. 我创建了一个klient-serwer程序,该程序仅通过其特定端口上的IP关闭计算机。我用C语言制作了所有东西,一切正常,我正在使用带有-Wall选项的gcc编译我的项目,并且我已经很清楚了结果。 But I had to create GUI so i decided to use QT Creator IDE, I transfered code from C into C++ and i made GUI. 但是我必须创建GUI,所以我决定使用QT Creator IDE,将代码从C传输到C ++,并制作了GUI。 Program works but I have to compile this using g++ with -Wall option. 程序可以工作,但是我必须使用带有-Wall选项的g ++进行编译。 Thing is, I cannot compile anything. 问题是,我什么都不能编译。

g++ my_project.cpp -o mypro -Wall

ERROR: fatal error: QMainWindow: directory don't exist (in my native language)
compilation terminated
(same with other source files)

Any ideas? 有任何想法吗? It's propably very easy, but believe me, I want to compile this and go to sleep. 大概很容易,但是相信我,我想编译一下并入睡。 Cheers 干杯

Why don't you use qmake? 为什么不使用qmake? First, you can edit your *.pro file and add any compiler flags you wish (see Mitch's comment). 首先,您可以编辑* .pro文件并添加所需的所有编译器标志(请参见Mitch的注释)。 Then, if you execute qmake and then make , it will show you a sequence of compilation commands with proper flags, linker and include paths and so on. 然后,如果先执行qmake然后执行make ,它将显示一系列带有适当标志,链接器和包含路径等的编译命令。 After that you can just reproduce that commands manually if your teacher wants so. 之后,如果您的老师愿意,您可以手动重现该命令。

The error shows that the compiler is trying to open QMainWindow as if it was a directory (if the translation is correct) or at least failing to locate where the include files for Qt are. 该错误表明编译器正在尝试打开QMainWindow ,就好像它是一个目录一样(如果转换正确),或者至少无法找到Qt的包含文件所在的位置。 You probably need to provide some -I option to hint the compiler as to where the Qt headers are, and make sure that the #include directives are correct in your code. 您可能需要提供-I选项,以提示编译器有关Qt标头的位置,并确保#include指令在您的代码中正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM