Qt5.8 在windows下mingw静态编译

原文链接:http://www.cnblogs.com/ike_li/p/6860089.html

官方对编译一些条件介绍:https://doc.qt.io/qt-5/windows-requirements.html

在默认情况下,用QtCreator编译程序时,使用的是动态编译。编译好的程序在运行时需要另外加上相应的Qt库文件,一大堆dll文件。如果想将生成的程序连同所需要的库一起完整地打包成一个可执行程序,那就需要使用静态编译。

在win7 x64 静态编译制作过程如下:

1. 安装Qt,全部勾选安装.   qt-opensource-windows-x86-mingw530-5.8.0.exe

2. 安装Perl, 下载地址:https://www.activestate.com/activeperl/downloads

  安装目录:D:\ProgramFiles\Perl64

  环境变量安装过程自动添加的,如果没有添加,手动添加: 

    D:\ProgramFiles\Perl64\site\bin;

    D:\ProgramFiles\Perl64\bin;

3. 安装Python,Windows x86 executable installer 下载地址: https://www.python.org/downloads/

    安装过程记得勾选添加PATH环境变量。

    安装目录:D:\ProgramFiles\Python36-32

   环境变量安装过程自动添加的,如果没有添加,手动添加: 

    D:\ProgramFiles\Python36-32\Scripts\;

    D:\ProgramFiles\Python36-32\;

4.打开Qt 5.8 for Desktop (MinGW 5.3.0 32 bit)

     

    4.1 输入以下命令检查gcc编译器配置是否正确

          gcc -v

    4.2  输入以下命令检查perl解释器配置是否正确

           perl -v

    4.3 输入以下命令检查python配置是否正确

          python

      按ctrl+z回车,退出python

5.在D:\ProgramFiles\Qt\Qt580\5.8新建一个文件夹mingw53_32_static,

   

   切换到Qt的源码目录

   cd D:\ProgramFiles\Qt\Qt580\5.8\Src  

   运行命令:    

configure.bat -confirm-license -opensource -platform win32-g++ -debug-and-release -static -prefix "D:\ProgramFiles\Qt\Qt580\5.8\mingw53_32_static" -qt-sqlite -qt-zlib -qt-libjpeg -qt-libpng -qt-xcb -qt-xkbcommon -qt-freetype -qt-pcre -qt-harfbuzz -opengl desktop -no-qml-debug -no-angle -nomake tests -nomake examples -skip qtwebengine -skip qtwebview -skip qt3d


 注:这里配置的时候,跳过了qtwebengine、qtwebview、qt3d,如果需要这些模块可以去掉skip

 

6.编译(大概需要3小时左右)

  mingw32-make -j2

   注:本处为2个线程编译,电脑好的可以开更多的线程,编译速度也更快

7.安装(需要30分钟左右,硬盘好的话会快点)

    mingw32-make install

8.新增静态编译

    打开Qt Creator -> 工具 -> 选项 -> 构建和运行 -> Qt Versions

     添加版本后,点击应用。

   

   

    构建套件:克隆一个,修改,注意Qt版本一定要记得选对。修改后,点击应用

  

 

9.配置编译器

   记事本打开D:\ProgramFiles\Qt\Qt580\5.8\mingw53_32_static\mkspecs\win32-g++\qmake.conf

   添加 一行QMAKE_LFLAGS = -static,修改 QMAKE_LFLAGS_DLL其值为-static

 

  

 10.新建工程选择 静态编译套件,编译出来就可以直接运行exe程序了。编译过程很慢,发布的时候最好选用release的,release的程序体积比debug小很多。

 

转载于:https://www.cnblogs.com/ike_li/p/6860089.html

展开阅读全文
博主设置当前文章不允许评论。

wxWidgets2.9.4静态编译,用MinGW啥版本的啊?

03-16

用codeblocks带的4.7静态编译时,老是报错rnrnrnrnrn[code=c]rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o)||In function `wx_jpeg_io_src':|rnG:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|202|undefined reference to `jpeg_resync_to_restart'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|243|undefined reference to `jpeg_std_error'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|259|undefined reference to `jpeg_destroy_decompress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|264|undefined reference to `jpeg_CreateDecompress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|266|undefined reference to `jpeg_read_header'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|291|undefined reference to `jpeg_start_decompress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|295|undefined reference to `jpeg_finish_decompress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|296|undefined reference to `jpeg_destroy_decompress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|308|undefined reference to `jpeg_read_scanlines'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|344|undefined reference to `jpeg_finish_decompress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|345|undefined reference to `jpeg_destroy_decompress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|421|undefined reference to `jpeg_std_error'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|437|undefined reference to `jpeg_destroy_compress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|441|undefined reference to `jpeg_CreateCompress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|448|undefined reference to `jpeg_set_defaults'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|457|undefined reference to `jpeg_set_quality'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|472|undefined reference to `jpeg_start_compress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|478|undefined reference to `jpeg_write_scanlines'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|480|undefined reference to `jpeg_finish_compress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagjpeg.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagjpeg.cpp|481|undefined reference to `jpeg_destroy_compress'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o)||In function `wxTIFFHandler':|rnG:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|111|undefined reference to `TIFFSetWarningHandler'|rnG:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|112|undefined reference to `TIFFSetErrorHandler'|rnG:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|111|undefined reference to `TIFFSetWarningHandler'|rnG:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|112|undefined reference to `TIFFSetErrorHandler'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o)||In function `Z10TIFFwxOpenR13wxInputStreamPKcS2_':|rnG:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|275|undefined reference to `TIFFClientOpen'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o)||In function `Z10TIFFwxOpenR14wxOutputStreamPKcS2_':|rnG:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|287|undefined reference to `TIFFClientOpen'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|311|undefined reference to `TIFFSetDirectory'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|318|undefined reference to `TIFFClose'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|326|undefined reference to `TIFFGetField'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|327|undefined reference to `TIFFGetField'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|330|undefined reference to `TIFFGetFieldDefaulted'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|333|undefined reference to `TIFFGetFieldDefaulted'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|338|undefined reference to `TIFFGetFieldDefaulted'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|341|undefined reference to `TIFFGetField'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|362|undefined reference to `TIFFClose'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|367|undefined reference to `_TIFFmalloc'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|376|undefined reference to `TIFFClose'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|389|undefined reference to `_TIFFfree'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|390|undefined reference to `TIFFClose'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|399|undefined reference to `TIFFGetField'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|403|undefined reference to `TIFFRGBAImageOK'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|415|undefined reference to `TIFFScanlineSize'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|415|undefined reference to `_TIFFmalloc'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|428|undefined reference to `TIFFReadScanline'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|459|undefined reference to `_TIFFfree'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|464|undefined reference to `TIFFReadRGBAImageOriented'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|475|undefined reference to `_TIFFfree'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|477|undefined reference to `TIFFClose'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|520|undefined reference to `TIFFGetFieldDefaulted'|rnG:\wxWidgets-2.9.4\lib\gcc_lib\libwxmsw29ud_core.a(corelib_imagtiff.o):G:\wxWidgets-2.9.4\build\msw\..\..\src\common\imagtiff.cpp|528|undefined reference to `TIFFGetFieldDefaulted'|rn||More errors follow but not being shown.|rn||Edit the max errors limit in compiler options...|rn||=== Build finished: 50 errors, 0 warnings (0 minutes, 12 seconds) ===|rnrn[/code] 论坛

没有更多推荐了,返回首页