Qt for Windows command line compilation

Source: Internet
Author: User

I used QT creator to compileCodeIt is completely feasible, but it encounters a small problem, that is, it cannot be compiled successfully with the command line.

However, after half a day of exploration, I finally solved the problem of command line compilation. Although it was troublesome, I should record it.

The solution is as follows:

1. First, find the QT installation path. my options are D:/QT/2009.04/bin;

2. Find the qtenv. BAT file in this path;

3. Open the folder where you need to create a project and copy the BAT file;

4. Open the command line. You can enter CMD in the running process and press Enter;

5. Run the qtenv command.

6. qmake-Project

7. qmake

8. mingw32-make clean (this step is to clear previously generated items if compilation fails, possibly because it has been compiled)

9. mingw32-make

Compiled successfully. You can run it.

I thought it was too troublesome. I tried to add the bin path and include path in the environment variables, but it was not very successful.

Qtenv. BAT file:

@ Echo off
Rem
Rem this file is generated
Rem
Echo setting up a mingw/Qt only environment...
Echo -- qtdir set to D:/QT/2009.04/QT
Echo -- path set to D:/QT/2009.04/QT/bin
Echo -- adding D:/QT/2009.04/bin to path
Echo -- adding % SystemRoot %/system32 to path
Echo -- qmakespec set to win32-g ++
Set qtdir = D:/QT/2009.04/QT
Set Path = D:/QT/2009.04/QT/bin
Set Path = % PATH %; D:/QT/2009.04/bin; D:/QT/2009.04/mingw/bin
Set Path = % PATH %; % SystemRoot %/system32
Set qmakespec = win32-g ++

 

It is reasonable to say that I add the environment variable path according to the above content, and then add two more environment variables qtdir. qmakespec should achieve the same effect, but it fails. If you know the reason, please do not give me your advice! Thank you !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.