8000 msvc · unetbootin/unetbootin Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Geza Kovacs edited this page Jan 24, 2017 · 1 revision

Compiling Qt Projects with Microsoft Visual C++

Setting up the build environment

Visual Studio 2005

If you wish to dynamically link Qt into your application (that is, i 10000 t will require external DLLs to be present upon runtime):
Download http://launchpad.net/unetbootin/trunk/trunk/+download/qt4.5.1-dynamic-msvc2005-debug.7z

If instead you wish to statically link Qt into your application (that is, no external libraries will be required upon runtime):
Download http://gkovacs.xvm.mit.edu/qt4.5.1-static-msvc2005-release-minimal.7z

Now extract your downloaded file, using 7-zip, to C:\Qt; a directory C:\Qt\qt4-msvc2005 should be created, with various subdirectories such as bin, include, and lib.

Now create a shortcut (hereby referred to as "Qt Command Prompt") that runs:

cmd /k "C:\Qt\qt4-msvc2005/qtenv.bat"

Visual Studio 2008

If you wish to dynamically link Qt into your application (that is, it will require external DLLs to be present upon runtime):
Download http://gkovacs.xvm.mit.edu/qt4.5.1-dynamic-msvc2008-debug.7z

Now extract your downloaded file, using 7-zip, to C:\Qt; a directory C:\Qt\qt4-msvc2008 should be created, with various subdirectories such as bin, include, and lib.

Now create a shortcut (hereby referred to as "Qt Command Prompt") that runs:

cmd /k "C:\Qt\qt4-msvc2005/qtenv.bat"

Compiling the software

The Visual C++ compiler and linker can be invoked either via the command line, using the nmake utility on a Makefile, or within the Visual Studio interface itself, using a project and a solution file. Since Qt projects use their own make system, qmake, which uses a .pro file (see documentation ), you will need to generate the appropriate makefiles or project/solution files before building. Note that you will have to repeat this cycle whenever you modify the .pro file.

Generating and using Makefiles

Open the Qt Command Prompt, cd to the directory containing the .pro file, and run:

qmake

A Makefile should be generated.

Building the Project

Now you can build the project using:

nmake

Running the Project

You can run the project by running the generated .exe file in the "release" or "debug" subdirectory.

If this is a console-based interface and you aren't seeing any output, edit the .pro file and add in:

CONFIG += console

Then rebuild the project and run again.

Debug and Release Modes

If you wish to switch between debug or release mode, edit the .pro file, and change (or add) the line:

CONFIG += debug

or

CONFIG += release

Cleaning the build directory

To clean out the build directory for a rebuild, run:

nmake clean

Generating and using Project and Solution Files

Using qmake:

Open the Qt Command Prompt, cd to the directory containing the .pro file, and run:

qmake -tp vc

A .vcproj file should be generated.

Now you can open the .vcproj file in Visual Studio and do the standard Build->Build Solution procedure to generate a solution file and build the project.

Using Qt Visual Studio Add-in:

Alternatively, if you have the Standard or Professional edition of Visual Studio, you can use the Qt Visual Studio Add-in to generate a project file; to do so:

Download and install http://www.qtsoftware.com/downloads/visual-studio-add-in

Open Visual Studio; there should now be a "Qt" menu on the top. Go to Qt->Qt Options, click "add", and select the path "C:\Qt\qt4-msvc2005"

Now go to Qt->Open Qt Project File, select the .pro file, and a .vcproj file should be generated.

Building the Project

Now you can open the .vcproj file in Visual Studio and do the standard Build->Build Solution procedure to generate a solution file and build the project.

Running the Project

You can run the project by going to "Debug->Start Without Debugging"

Debug and Release Modes

If you wish to switch between debug or release mode, go to Build->Configuration Manager, and select either "Debug" or "Release" as the Active solution configuration.

Cleaning the build directory

To clean the build directory, go to "Build->Clean Solution"

See Also

Qt4 with Visual Studio
Qt4 With Visual Studio and static C runtime

Clone this wiki locally
0