qt5.x app on Mac OS X and Windows platform Publishing process

Source: Internet
Author: User

QT is a very powerful cross-platform development tool that can now be developed for Mac OS X,Windows,Linux,Android,IOS and other platforms. App. For android and IOS platforms, publishing is relatively easy, for example,the Android platform is generated by apk files uploaded to Android devices, So install the apk file directly. But the application of PC platforms (Mac OS X, Windows, and Linux) is abit of a hassle when it comes to publishing.

This article focuses on Mac OS X and Windows platform publishing process. Applications running on these two platforms are called executable programs. windows platform executable file extension is exe Mac OS x platform executables typically do not have an extension, but the standard Mac os x The execution program is not just one file, but a bundle bundle bundle directory structure.

Let's take a look . How QT5 for Mac OS X is published. Some of you might think that it would be okay to replicate the QT -generated Bundle directly to other OS X systems. In fact, this is not possible, because the QT generated Bundle can be run in qt , because the native related Library exists, and qt Know where these guys are (certainly not in bundles ). If you copy bundles to other OS X systems, youwill not be able to find them if QT is not installed . So nature can't run anymore.

So what should we do? There are actually two methods: static compilation and dynamic compilation.

static compilation, by definition, is all the The Library is compiled into the executable file. It is very convenient to do so. However, when the application is very large, the compilation time may be longer, and the resulting executable will be large. Of course, there are bigger problems, from the official web download QT are dynamically compiled version, to static compilation, you need to re-use the static way to compile the entire QT, time is longer, after the completion of the compilation around 2GB . Of course, if you want to do this classmate, you do not have to look back, feel the download QT Source code, and then compile it.

Now let's talk about the dynamic compilation process. If the installation version of QT downloaded from the official website is dynamically compiled, that is, the resulting executable cannot be executed independently.

we can use QT randomly creates and compiles a project and compiles it. Assuming the project name is CoderQuestion1, the default build directory is as follows:

/users/lining/build-coderquestion1-desktop_qt_5_4_0_clang_64bit-debug

into the directory, you will see that there is a Coderquestion1.app. This is not a file, but a directory, but OS X system sees a directory extension is the app, it will beconsidered a Bundle directory, so the double-click will be executed directly (of course, must be true Bundle). The right-click menu now selects "Show Package Contents" and is then entered in that directory. By default, the directory structure is as shown.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/79/wKioL1XkYNvyGSUlAADlnahKOaA867.jpg "title=" 01.png "alt=" Wkiol1xkynvygsulaadlnahkoaa867.jpg "/>


in the the CoderQuestion1 in the MacOS directory is actually an executable file, and the other directory is the resource file. Obviously, such a directory structure is too thin to replicate to other OS X Systems, and it's hard to keep it running successfully.

So what should we do? Nonsense, of course, is copying the relevant files to this Bundle . So how do we know what files should be copied? In fact , it is easy to do this with the Otool tool. Now go through the Console to the MacOS directory in the Bundle and execute the following command.

Otool-lcoderquestion1

After you execute the Wrap command, the information such as is displayed.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/79/wKioL1XkYaqQyHVzAA8oWxtauu0170.jpg "width=" 600 " height= "331" alt= "Wkiol1xkyaqqyhvzaa8owxtauu0170.jpg"/>

Although this is a list of required Library, but one copy is too cumbersome, and beginners estimate that it is not known which subdirectories should be copied to the Bundle . Of course, it's not a good thing to copy these things, but there are other things that need to be done, and in short, it's too cumbersome to handle the work by hand.

fortunately QT provides a handy packaging tool for MACDEPLOYQT, which is located in the following directory.

/users/lining/qt5.4.0/5.4/clang_64/bin

for convenience, you can add this directory to the the PATH environment variable.

now just execute the following command and the system will automatically rational Bundles, putting the relevant files and directories in the bundle's relevant location.

MACDEPLOYQT Coderquestion1.app

However, be sure to note that the Coderquestion1.app Copy and use MACDEPLOYQT to process the copy. Because if you deal with the original Bundle, it can cause source code compilation problems.

after the process is finished, the directory structure of the bundle is, obviously,the MACDEPLOYQT command places the relevant files and directories in the bundle . Now the finished Coderquestion1.app is copied to any OS X system and can be run regardless of whether QT is installed or not. Of course, you can also package it as a DMG file, which makes it look cooler.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/7C/wKiom1XkX8izREcZAAR3H_JMzXk219.jpg "width=" 500 " height= "893" alt= "wkiom1xkx8izreczaar3h_jmzxk219.jpg"/>

OK, now let 's take a look at how the qtfor Windows app is packaged. QT under Windows also has a tool similar to MACDEPLOYQT , but called Windeployqt.exe, which is located in the following directory.

C:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl\bin

Although this is a command-line program, do not use the Windows 's normal console enters the directory, to use the console of QT , for example, this example uses the Visual Studio2013 version, so the console in the black box should be used.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/7C/wKiom1XkYBbQO18WAATPlHD9ycs472.jpg "width=" 500 " height= "568" alt= "Wkiom1xkybbqo18waatplhd9ycs472.jpg"/>

now enter the console and will The QT- generated exe file (in this case , CoderQuestion1.exe) is copied to a different directory (for example,d:\release) and executes the following command.

Windeployqtd:\release\coderquestion1.exe

after executing this command, the system will place the relevant files and directories in the D:\release directory. However , if you do not have Visual Studio2013 installed, you willstill not be able to run it on other Windows systems. This is due to the lack of a relevant Library for Visual Studio2013. So how do you know which Library is missing ?

One approach is to use the relevant tools to view, and you can use theDependencywalker, this is a cross-platform tool that can be used to viewWindowsin theExe,Dllthe dependencies of the binary files. You can download the tool online. For example, use this tool to openCoderQuestion1.exe, you will find in additionQtof theDll, there are two otherVsof theDll(MSVCP120. Dlland theMSVCR120. Dll). The reader canVsthe installation directory to search for these two files. Be aware, however, that selecting64bit or32bit ofDll(copy these two files toD:\releasedirectory), do not selectArmthe same name as the processorDll, otherwise inx86cannot be run on the machine.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/7C/wKiom1XkYFfA-CREAAUGjZV6180396.jpg "width=" 600 " height= "339" alt= "Wkiom1xkyffa-creaaugjzv6180396.jpg"/>

there is, of course, an easier way to replicate directly VS Runtime, you can find the runtime of VS2013 in the following directory . If it is a system, you need to change the x64 to x86.

C:\Program Files (x86) \microsoft Visual Studio 12.0\VC\REDIST\X64\MICROSOFT.VC120.CRT

3 files, of which two are preceded by dependencywalker Tool to locate the file. Now this 3 files copied to D:\release directory. ok release directory copied to any Windows on the machine (must be 64 bit system), it can all run. Even if you do not have vs2013

If you are using a three- bit Windows, you need to install the QT version on the four-bit machine , recompile , and copy the VS2013 a medium -level DLL . The final structure of the D:\release directory is as shown.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/79/wKioL1XkYrKDbd5DAAQjbdPtRHI195.jpg "width=" 600 " height= "357" alt= "Wkiol1xkyrkdbd5daaqjbdptrhi195.jpg"/>

This article is from "Li Ning's Geek World" blog, please make sure to keep this source http://androidguy.blog.51cto.com/974126/1690306

qt5.x app on Mac OS X and Windows platform Publishing process

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.