`

QT应用程序的发布(静态和动态编译+生成有图标的exe)

    博客分类:
  • QT
阅读更多

1. 静态编译

优点发布简单,单一文件,在移植时如果空间足够,采用静态编译比较可靠
缺点库文件很大,更新程序版本不方便。每次升级,都要重新分发所有的内容。

对QT而言,需要重新编译静态库(非常耗时),且插件的使用比较麻烦http://hi.baidu.com/cyclone/blog/item/25b262d9337a172310df9b78.html

要查询应用程序关联的库,可用命令 ldd ./application

 

 Static linking is often the safest and easiest way to distribute an application on Unix since it 

relieves you from the task of distributing the Qt libraries and ensuring that they are located in the 

default search path for libraries on the target system.

 

We have two challenges when deploying the Plug & Paint application using the shared libraries 

approach: The Qt runtime has to be correctly redistributed along with the application executable, 

and the plugins have to be installed in the correct location on the target system so that the

 application can find them.

 

2. 动态编译

优点更新方便,发布多个产品时,可以统一使用一个库。
缺点文件多、杂。

采用release方式编译(QT Creator下Projects-->Build steps-->qmake bulid configuration或在pro文件中CONFIG+=release)一般需要QT/qt/bin下的libgcc_s_dw2-1.dll qtCore4.dll QtGui4.dll mingwm10.dll。此外,还应添加相应的plugin如imageformats(对于图片加载)也可以使用NSIS发布可供安装的QT程序,参考http://blog.csdn.net/dbzhang800/article/details/6411870

 

3. 生成有图标的exe文件

QT Creator虽然可以轻松地设置窗口的小图标,但并没有提供设置exe文件图标的功能。

其实做起来并不难。

·首先当然要准备一个.ico图标文件(假定为myIcon.ico),将其复制到工程目录当中(.pro文件所在的目录)。

·然后在QT Creator中Ctrl+N或 File --> New File or Project

选择General中的Text File

名称填写为.rc文件(如myRc.rc)

在里面只用写一行:

IDI_ICON1  ICON  DISCARDABLE  "myIcon.ico"

·编辑.pro文件,里面应该有:

OTHER_FILES+= \

 apprc.rc

在其下再添加一行(如果没有上面的内容也没事):

RC_FILE = \
    myRc.rc

·最后编译一下就好了,新生成的exe文件的图标就会变成myIcon.ico的样子

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics