C++ Qt framework: qmake exits with error code 2, c

2020-07-10 12:04发布

问题:

As the title says, I am having an issue with 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:

Cannot find file: /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'

Yet when I go to the folder, I can see the test.pro file there, so I don't see why Qt is unhappy.

Did anybody have had a similar problem? I couldn't find any similar question so far. Thanks in advance for you help, Regards

回答1:

Are you sure that you don't have space or other 'weird' characters in your project's path? If so, Qt is unhappy.

You may also try to delete the *.pro.user file and try to compile again. 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:

  1. qmake -project
  2. mingw32-make

If this still can't get your project compiled, you should check your Qt installation.



回答2:

In my case removing non-ascii characters from the path solved the problem. Spaces are fine, at least from my experience.



回答3:

I found another solution that worked for me.

QT is cross-platform tool, so it needs some limitations and restrictions. One of this restriction is correct path to project. It CAN'T contain any spaces!!!

For example

D:\Qt project\project -- wrong

is WRONG. (notice space between Qt and Project). Instead use something like this

D:\Qt_project\project -- correct