QT 4.6.2 integrates with Visual Studio 2005 (compilation method, and problems encountered in the middle)

Source: Internet
Author: User
Tags tmp file

In Thyssen almost half a month, haha, time is fast, live very substantial, recently study QT, first of all, must learn to install, the most basic will not let alone the following. Gossip less, go to the point, Basic installation steps on the Internet, but refer to a majority of the situation is not installed, there is always such a problem, basically I refer to the following steps:

Qt 4.6.2 Although the LGPL protocol has been added, it also prevents us from using QT in vs. Because the free open source version only provides the GCC compiled binary library, but does not have the VC compiles the binary library, only the commercial version has the VS compiles the dll,lib and so on Windows the binary library.

Furthermore, VC compilers are much stronger than GCC, and the debugger is exceptionally powerful. Although the Qt creator is cool, it is still very rough. Many people are also more familiar with the VS interface. To compile a binary library with vs:

1. Download and install the Qt-sdk-win-opensource-2010.02.1.exe and install to the default c:\qt\2010.02.1. It contains MINGGW and Qt Creator, as well as pre-compiled binaries (compiled with GCC). You can start your development work directly with QT Creator, without any additional configuration.

2. Copy the entire catalogue c:\qt\2010.02.1 to C:\QT\4.6.2-VC. We will modify the directory C:\QT\4.6.2-VC, using VC + + to compile the required libraries. Both directories can exist at the same time, and QT uses c:\qt\2010.02.1,visual Studio to use C:\QT\4.6.2-VC.

3. Modify the Vsvars32.bat in C:\Program Files\Microsoft Visual Studio 8\common7\tools\ to add QT directories in the environment variable path, such as C:\QT\4.5.0-VC\QT, On the Include Add C:\qt\4.5.0-vc\qt\include, add C:\qt\4.5.0-vc\qt\include in lib, such as:

@set path=c:\qt\4.6.2-vc\qt;c:\program Files\Microsoft Visual Studio 8\common7\ide;c:\program Files\Microsoft Visual Studio 8\vc\bin;c:\program Files\Microsoft Visual Studio 8\common7\tools;c:\windows\microsoft.net\framework\v3.5;c : \windows\microsoft.net\framework\v2.0.50727;c:\program Files\Microsoft Visual Studio 8\vc\vcpackages;%path%

@set include=c:\qt\4.6.2-vc\qt\include;c:\program Files\Microsoft Visual Studio 8\vc\atlmfc\include;c:\program Files \microsoft Visual Studio 8\vc\include;%i Nclude%

@set lib=c:\qt\4.6.2-vc\qt\lib;c:\program Files\Microsoft Visual Studio 8\vc\atlmfc\lib;c:\program Files\Microsoft Visual Studio 8\vc\lib;%lib%

Open a CMD command line window, drag this file to execute, so that you open the CMD has the environment variables set above, but these variables only for your current CMD, do not change the native configuration, so do not close the cmd window, you need to complete the next command in this CMD window.

(the original is done in accordance with the third step, the first time I also follow this step to compile, but because of the following problems, then manually add C:\Qt\qt-4.3.1\bin in the path of the system environment variable, note that this should correspond to the installation directory, in fact, the effect is the same as above)

4. Implementation

C:\> CD C:\QT\4.5.0-VC\QT

C:\qt\4.5.0-vc\qt> Configure-platform win32-msvc2005

Above this line of command, you can change according to your own needs, but note that you must indicate the parameters after-platform, indicating that you want to configure the version of VS. This step takes some time, about 60 minutes.

5. Type nmake, enter, and start compiling. This step with a long, my probably compiled for 3 hours ~ ~

Note: If you are under Windows 7, most of this will fail, because the Win 7 SDK has a bug, the MT program cannot add manifest to binary when there is no resouce region in binary (reference:/HTTP download.microsoft.com/download/8/8/0/8808a472-6450-4723-9c87-977069714b27/releasenotes.htm), so we need to make some changes before we can,

The first step is to execute the following command under CMD

C:\qt\4.6.2-vc\qt>echo.>hello.rc

C:\qt\4.6.2-vc\qt> rc.exe/r hello.rc

Get the C:\qt\4.6.2-vc\qt\hello.res resource file.

The second step, modify the Qmake configuration file, so that the Makefile link command will be hello.res linked to binary. Modify the 52nd behavior of the qmake.conf file under the mkspecs\win32-msvc2005 directory

Qmake_lflags =/nologo C:\Qt\4.6.2-vc\qt\hello.res

As a result, any link command will necessarily link the hello.res file.

Before you can enter NMAKE to start compiling.

6. Install the official vs plugin Qt-vs-addin-1.0.0-beta.exe,

7. Start Visual Studio, select the menu "QT->QT Options", click "Add" on the "Qt verions" tab, and the Version name is filled in, for example "QT4.6.2-VC", the path is entered "C:\Qt\4.6.2 -VC\QT ". (online information has said to establish environmental variables qtdir= C:\QT\4.6.2-VC\QT, I personally think is not necessary).

8. Now that your visual Studio is fully equipped with all the functions of QT, create a new QT project compile run and try it!

(After compiling, click Debug-debug without debuggine in VS to see how the program works, but

If you directly to the debug directory double-click the exe file, you will be prompted to find QtCore4d.dll, then you need to add C:\Qt\4.5.0-vc\qt\bin to the PATH environment variable, this directory and QtCore4.dll, are compiled above).

However, your current environment is integrated with the LGPL version of Qt vs, with the commercial version or a little different. For example, the QT Desiner (Resource Designer) is not embedded in VS, need to be executed via the menu "Qt->launch Desiner" (commercial version directly double-click the. ui file will start Qt Desiner). But it doesn't matter, just a few more mouse clicks.

Click "Qt->launch linguist" to launch Qt linguist, which is a localization tool and useful.

Next, the following questions were encountered:

Code
Creating library: \.. \.. \.. \lib\qtwebkitd4.lib and objects: \.. \.. \.. \lib\qtwebkitd4.e
Xp
QNetworkReplyHandler.obj:error LNK2001: unresolved external symbol "Public:virtual St
Ruct Qmetaobject Const * __thiscall webcore::formdataiodevice::metaobject (void) c
Onst "([email protected]@[email protected]@[email protected] @XZ)
QNetworkReplyHandler.obj:error LNK2001: unresolved external symbol "Public:virtual vo"
ID * __thiscall webcore::formdataiodevice::qt_metacast (char const *) "(? Qt_metac
[Email protected]@[email protected]@[email protected])
QNetworkReplyHandler.obj:error LNK2001: unresolved external symbol "Public:virtual in
T __thiscall Webcore::formdataiodevice::qt_metacall (enum qmetaobject::call,int,v
OID * *) "([email protected]@[email protected]@[email protected]@ @HPAPAX
@z)
QNetworkReplyHandler.obj:error LNK2001: unresolved external symbol "Public:virtual St
Ruct Qmetaobject Const * __thiscall webcore::qnetworkreplyhandler::metaobject (vo
ID) const "([email protected]@[email protected]@[email protected] @XZ)
QNetworkReplyHandler.obj:error LNK2001: unresolved external symbol "Public:virtual vo"
ID * __thiscall webcore::qnetworkreplyhandler::qt_metacast (char const *) "(? Qt_m
[Email protected]@[email protected]@[email protected])
QNetworkReplyHandler.obj:error LNK2001: unresolved external symbol "Public:virtual in
T __thiscall Webcore::qnetworkreplyhandler::qt_metacall (enum qmetaobject::call,i
Nt,void *) "([email protected]@[email protected]@[email protected]
@@[email protected])
QNetworkReplyHandler.obj:error LNK2019: unresolved external symbol "Protected:void __
ThisCall Webcore::qnetworkreplyhandler::p rocessqueueditems (void) "(? Processqueue
[email protected]@[email protected] @IAEXXZ), the symbol is in the function "Public:void __thisc
All Webcore::qnetworkreplyhandler::setloadmode (enum Webcore::qnetworkreplyhandle
R::loadmode) "([email protected]@[email protected]@[email protected]@@z)
is referenced in
FrameLoaderClientQt.obj:error LNK2019: unresolved external symbol "Protected:void __t
Hiscall qwebpage::unsupportedcontent (class qnetworkreply *) "(? Unsupportedconten
[Email Protected]@@[email protected]@@z], the symbol in the function "public:virtual void __this
Call WEBCORE::FRAMELOADERCLIENTQT::d ownload (class Webcore::resourcehandle *,stru
CT webcore::resourcerequest const &,struct webcore::resourcerequest const &,CLAS
S Webcore::resourceresponse const &) "([email protected]@[email protected] @UA
[Email protected]@[email protected]@[email protected]@@z) is referenced
FrameLoaderClientQt.obj:error LNK2019: unresolved external symbol "Protected:void __t
Hiscall qwebpage::d ownloadrequested (class Qnetworkrequest const &) "(? Downloadre
[Email Protected]@@[email protected]@@z], the symbol in the function "Public:virtual voi
D __thiscall webcore::frameloaderclientqt::startdownload (struct WEBCORE::RESOURC
Erequest Const &) "([email protected]@[email protected] @UAEXABUResourceR
Referenced in [email protected]@@z]
.. \.. \.. \.. \lib\qtwebkitd4.dll:fatal error Lnk1120:9 an unresolved external command
Nmake:fatal error U1077: "" C:\Program Files\Microsoft Visual Studio 8\vc\bin\
Link. EXE "": Return Code "0x460"
Stop.
Nmake:fatal error U1077: "" C:\Program Files\Microsoft Visual Studio 8\vc\bin\
Nmake.exe "": Return Code "0x2"
Stop.
Nmake:fatal error U1077: "CD": Return Code "0x2"
Stop.

Workaround: Delete the mocinclude.tmp file under the QT directory, the approximate path is as follows: src/3rdparty/webkit/webcore/tmp/moc/{debug,release}_shared/ Mocinclude.tmp, then nmake again, and then the following error occurred:

Code
Api\qscriptextensionplugin.h (+): error:undefined interface  
Nmake:fatal error U1077: "C:\Qt\4.6.2-vc\qt\bin\moc.exe": Return code "0x1"
Stop.
Nmake:fatal error U1077: "" C:\Program Files\Microsoft Visual Studio 8\vc\bin\
Nmake.exe "": Return Code "0x2"
Stop.
Nmake:fatal error U1077: "CD": Return Code "0x2"
Stop.

The solution is to: qt/src/script/tmp/moc/debug_shared/mocinclude.tmp,

Qt/src/script/tmp/moc/release_shared/mocinclude.tmp Delete, and then continue compiling is OK.

Http://www.cnblogs.com/bingcaihuang/archive/2010/12/02/1894005.html

QT 4.6.2 integrates with Visual Studio 2005 (compilation method, and problems encountered in the middle)

Related Article

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.