Pro-Test VS2010 pure static compilation QT4.8.0, implement VS2010 compile and debug qt program, qtcreator static release program (illustrated, very detailed)

Source: Internet
Author: User
Tags visual studio 2010



Download the source code, note that it must be a source compression package such as Qt-everywhere-opensource-src-4.8.0.zip, not QT released by the compiled version of the standard library such as Qt-win-opensource-4.8.0-vs2010.exe , these versions are only dynamically compiled, not what we need. Only with the source package to do a true pure static compilation, if the QT official website compiled by the standard library. exe file to compile, there may be various errors, and the file is huge after the compilation, I was here around a lot of bend, please children shoes attention!! May be some old birds will be jokes, but I am the most serious attitude to tell the rookie, online check information blog, must pay attention to the text details of the blog, sometimes a few words can make you cost a lot of strength, around the wall.



First unzip the source package to the location where you want to save the compilation, note that the file directory must not contain Chinese and space!



Due to some problems with Qt4.8 in the VS environment, in order to avoid compilation midway, I summed up 3 places to be modified.



(1) Delete the SYNCQT and Syncqt.dat files in the bin directory of the source package, if you do not trust it can be renamed or cut to another location. If you do not modify the Perl not found in Environment-cannot run SYNCQT error will occur.



(2) Modify the qmake.conf file under \mkspecs\win32-msvc2010.
Qmake_cflags=-nologo-zm200-zc:wchar_t-changed into qmake_cflags=-nologo-zm200-zc:wchar_t
Notice the "-" difference at the end. If you do not modify the future if you have a project using WCHAR_T,QT but compiled into wchar_t-, compile will lead to connection errors, the hint can not find qwstring;
Qmake_cflags_release,qmake_cflags_release_with_debuginfo,qmake_cflags_debug These 3 places behind the MD,MDD corresponding to change into MT,MTD, To implement the QT program in a computer that does not have a VC library.



(3) Modify the DefaultLocalizationStrategy.cpp under Src\3rdparty\webkit\source\webcore\platform, position to 327 lines, and replace the bank with return Web_ui_ STRING ("Look Up \" <selection>\ "," Look up context menu item with selected word "). Replace (" <selection> ", Trun Catedstringforlookupmenuitem (selectedstring)); (due to Word automatic typesetting problems, please direct the above English part of the full copy, in fact, they are a line, do not copy the branch).
If you do not modify the compile WebKit will appear when the U1077 error occurs.



VS2010 under the pure static compilation, need to VS2010 the command prompt, I installed the Chinese version of Visual studio2010, my opening steps are as follows (English version of their own): Start->microsoft Visual Studio 2010- >visual Studio tools->visual Studio Command Prompt (2010), open the following window:






is VS2010 automatically help me to configure the environment variables, has entered the VS2010 VC directory. I first encountered an automatic configuration environment variable error, in the second line of English, the content is probably unable to determine the VC environment and the location of the VC, at that time searched all kinds of information and try the various methods on the Internet, Chinese language of the website of the various suggestions, can not, almost let me lose confidence. At that time, a angry, restart the computer, go out and walk and their own thinking of several methods, came back just want to try, did not expect to reopen command prompt, incredibly again automatically can, really surprise ah. Finally think about it, then the error may be the first install the SDK, and then randomly according to the method on the Internet, manually modified the computer environment variables, and then this problem occurs. Then restart the computer before, the previously manually added environment variables are all deleted, restart after restarting the command prompt resumed. Hope to have the same problem with my children's shoes can be helpful.



The previous paragraph is a digression, if your VS has automatically configured the environment variable for you, as shown above, enter the command into the source package directory. Here to teach some command line novice, the veteran, please skip directly, such as your current directory in the C disk, and your source package in D, then input "D:", enter, enter into the D disk. You can use the CD to enter the directory you want to enter, such as CD qt\4.8.0, you can enter into the D:\Qt\4.8.0, in each directory, you can use the dir command to view all the files in the current directory, like the LS command under Linux. I entered my extracted source package directory, I have renamed to 4.8.0. The command prompt is as follows:






The next step is to make the configuration work before compiling. To perform the configuration, the complete command is as follows:



Configure-debug-and-release-fast-static-platform Win32-msvc2010-no-qt3support-script-scripttools-qt-zlib- Qt-libpng-qt-libmng-qt-libtiff-qt-libjpeg-qt-sql-sqlite-plugin-sql-sqlite-qt-style-windows-qt-style-windowsxp- Qt-style-windowsvista-qt-style-plastique-qt-style-cleanlooks-qt-style-motif-qt-style-cde-nomake Demos-nomake Examples-nomake DOCS–MP



Please refer to my other blog post for each command description: TheQt configure parameter is not fully explained http://www.cnblogs.com/elect-fans/archive/2012/03/28/2420647.html



Recommend the Debug and release versions are compiled, so VS2010 compiled debugging QT program will not appear link error, I test, some people say as long as compile release on it, but I personally think more compile a debug, add a little space, and the following command to eliminate the demos and other files compiled, I finally compiled the finished file is 3.6G, for the current computer hard disk is a drizzle. The final command-nomake demos-nomake examples-nomake docs, which does not mutate demos,exampls,docs files, so that both the compilation speed and the compiled volume can be reduced. -MP is suitable for multi-core users to improve the speed of compilation,-fast is also very important, see the above blog details.



To perform the configuration, you will be asked whether to use open source (open source version) or commercial version, enter "O" to select Open source version, ask whether you agree to the terms, enter "Y" to agree, start the configuration process, until the prompt configuration is complete, you can next nmake to start the compilation.



Input nmake, compile, compile the process for several hours (specific to the PC configuration), compile the best to turn off the firewall,and so on, you can do other things, look at the Web, movies and the like, but do not run large programs, otherwise it will severely reduce the compilation speed.






The compilation completed successfully, as shown, and you can close the command prompt. I was looking at the information on the Internet, the execution of NMAKE Clean,nmake Confclean, resulting in the subsequent VS2010 compiled QT program and QTSDK compiler program has a variety of problems, such as can not find config.h,qtmaind.lib and so on. Therefore, it is strongly recommended that the compilation be successful, and do not perform the above two cleanup tasks. Previously also tried to add-prex in the Configure to specify the NMAKE install installation directory, after the experiment, compiled, it is possible to implement a static library link after compilation, and in Qtcreator compile a static program, but in the VS2010 compiler program, There are many warnings that the PDB cannot be found, so discard it.



More links please visit my blog: http://www.cnblogs.com/elect-fans/



Next installs the VS plugin, the installation file is Qt-vs-addin-1.1.10.exe, the following is the installation procedure as well as installs the option.









After the installation is complete, open the VS2010, you can use the QT menu to locate the Qt compile library and open the Pro project file, or you can create the QT project through the new Project project.











After opening the QT project, slightly wait for the bottom left corner to prompt the associated file contains the prompt end, the "Ready" prompt, you can compile as a normal VC program, click the "Compile" button to compile and debugging through the Debug menu. Note that the VS2010 is primarily used for debugging, and it is best to publish the final static link program through the Qtcreator in QTSDK.



To install QTSDK, the following are the installation procedures and installation options:












After the installation is complete, open qtcreator, and in the "Tools", "Options", "Build and Run", "QT version", manually add the Qmake.exe tools just statically compiled QT.









After the configuration is complete, you can then open the QT project and publish the static link QT program through the project Settings!!



I pass 4 days n times to try, personally test various materials and methods, finally through the practice successfully completed the VS2010 static compilation configuration Qt, during the encounter all kinds of problems, finally solved, because of the reason of the space is not a statement, but this article is I step by step out of, dare not say the most suitable, but certainly effective! please pay attention to my blog: http://www.cnblogs.com/elect-fans/ , to explore learning together.



Http://www.cnblogs.com/elect-fans/archive/2012/03/29/2422816.html



Pro-Test VS2010 pure static compilation QT4.8.0, implement VS2010 compile and debug qt program, qtcreator static release program (illustrated, very detailed)


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.