简体   繁体   English

C ++ Qt框架:qmake退出时出现错误代码2,找不到project.pro文件,但它就在那里

[英]C++ Qt framework: qmake exits with error code 2, can not find project.pro file, yet it's there

As the title says, I am having an issue with Qt Creator. 正如标题所说,我遇到了Qt Creator的问题。 I started to play with it and created a main() with a some code in it and when I wanted to compile it to see how it would appear on the screen, I am unable to do so, I see the following error: 我开始玩它并创建一个带有一些代码的main(),当我想编译它以查看它将如何出现在屏幕上时,我无法这样做,我看到以下错误:

Cannot find file: /Users/Eugene/Documents/Qt/Test/test.pro. 找不到文件:/Users/Eugene/Documents/Qt/Test/test.pro。 Le processus "/Users/Eugene/QtSDK/Desktop/Qt/473/gcc/bin/qmake" terminated with error cade 2. Error during the compilation of the project Test (build : Desktop) during the step 'qmake' Le processus“/ Users / Eugene / QtSDK / Desktop / Qt / 473 / gcc / bin / qmake”以错误cade结束2.在“qmake”步骤中编译项目Test(build:Desktop)时出错

Yet when I go to the folder, I can see the test.pro file there, so I don't see why Qt is unhappy. 然而,当我去文件夹时,我可以在那里看到test.pro文件,所以我不明白为什么Qt不开心。

Did anybody have had a similar problem? 有没有人有类似的问题? I couldn't find any similar question so far. 到目前为止,我找不到任何类似的问题。 Thanks in advance for you help, Regards 在此先感谢您的帮助,此致

Are you sure that you don't have space or other 'weird' characters in your project's path? 您确定项目路径中没有空格或其他“奇怪”字符吗? If so, Qt is unhappy. 如果是这样,Qt不高兴。

You may also try to delete the *.pro.user file and try to compile again. 您也可以尝试删除*.pro.user文件并尝试再次编译。 If unfortunately neither of them work, you can try to compile your project on the command line. 如果遗憾的是它们都不起作用,您可以尝试在命令行上编译项目。

cd to the root directory of your project and: cd到项目的根目录并:

  1. qmake -project
  2. mingw32-make

If this still can't get your project compiled, you should check your Qt installation. 如果这仍然无法编译您的项目,您应该检查您的Qt安装。

In my case removing non-ascii characters from the path solved the problem. 在我的情况下从路径中删除非ascii字符解决了问题。 Spaces are fine, at least from my experience. 空间很好,至少从我的经验来看。

I found another solution that worked for me. 我找到了另一个对我有用的解决方案。

QT is cross-platform tool, so it needs some limitations and restrictions. QT是跨平台工具,因此需要一些限制和限制。 One of this restriction is correct path to project. 其中一个限制是正确的项目路径。 It CAN'T contain any spaces!!! 它不能包含任何空格!

For example 例如

D:\\Qt project\\project -- wrong D:\\ Qt project \\ project - 错了

is WRONG. 是错的。 (notice space between Qt and Project). (注意Qt和Project之间的空间)。 Instead use something like this 而是使用这样的东西

D:\\Qt_project\\project -- correct D:\\ Qt_project \\ project - 正确

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

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