Qt creator compiles and uses the static library of QT

Source: Internet
Author: User

I started to learn QT creator. Today I installed it on both Linux and Windows. in Linux, I can compile and execute my ownProgramIn Windows, a problem occurs. When executing the program, the system prompts "mingwm10.dll cannot be found". The solution is to statically compile the QT library.

Steps:

1. Call QT command prompt in the Start Menu,

2. Run configure-release-static-fast.
3 Execute Command mingw32-make

4 Execute Command mingw32-make clean

The above step is the process of compiling the QT static library. It is taken from the blog of the netizen lsyer. Now, some suffixes are generated under the QT \ 2009.03 \ QT \ lib directory. the static library file of A, and then compile your application again, then an error is reported. The error message prompts that qtguid and qtcored cannot be found, change libqtguid4.a and libqtcored4.a In the QT \ 2009.03 \ QT \ lib directory to libqtguid. A And libqtcored. A can also be copied and renamed.

Next, compile your own application. When executing the application hello.exe, the system still prompts that the QT library cannot be found. Later, it is found that the debug version is compiled, as long as you open the projects column on the left, check the release check box and compile it again. The executable file is generated under the release directory: copy the mingwm10.dll in the \ QT \ 2009.03 \ mingw \ bin directory to the release directory and put it together with the executable program. Now the program can be executed normally, no longer prompts that the QT library cannot be found.

 

 

1.Modify configuration file(1) Qt creator

Qt 4.3 and newer

Edit <qtdir> \ mkspecs \ win32-g ++ \ qmake. conf:

Change

Qmake_lflags =-enable-stdcall-fixup-wl,-enable-auto-import-wl,-enable-runtime-pseudo-reloc

To (add-static)

Qmake_lflags =-static-enable-stdcall-fixup-wl,-enable-auto-import-wl,-enable-runtime-pseudo do-reloc


 

(2 ). Visual Studio

 

 

See trolltech's KnowledgeBase: Why does a statically built QT use the Dynamic Visual Studio runtime libraries? Do I need to deploy those with my application?

Applications built with msvc depend on msvc *. dll. Following changes must be done to mkspecs in order to eliminate this dependency.

edit \ mkspecs \ win32-X \ qmake. conf, where 'x' stands for the version of Visual Studio:

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.