Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

qt5 - Building Qt 5 on Linux, for Windows

I wanted to migrate my Qt 4 app to use Qt 5 instead. These instructions failed, due to some differences with how MXE builds Qt 5, including the fact that it uses modularised Qt tarballs, instead of one large tarball.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here are the full instructions:

  • Get it:

    git clone https://github.com/mxe/mxe.git
    
  • Install build dependencies

  • Build Qt 5 for Windows:

    cd mxe && make qtbase
    

    This will first build its dependencies and the cross-build tools; It should take less than an hour on a fast machine with decent internet access.

    Due to the new modular nature of Qt 5, various major Qt components are now in different tarballs. The one selected above, qtbase, should give you enough functionality to run ordinary GUI apps, which is all I needed for my own (smallish) app.

    If you want to build all of Qt 5 instead, you'll need to run make qt5 (instead of make qtbase). Note that it will take a lot longer to complete, so be sure that you need the extra functionality.

  • Get to the directory of your app, and run the Qt Makefile generator tool:

    <mxe root>/usr/bin/i686-w64-mingw32.static-qmake-qt5
    
  • Build your project:

    make
    
  • You should find the binary in the ./release directory:

    wine release/foo.exe
    

Some notes:

  • This was tested on my 64-bit Debian 8, and on Windows of course.

  • The output is a 32-bit static executable, which will work well on 64-bit Windows.

  • If you want a 64-bit executable, build Qt with:

    make MXE_TARGETS=x86_64-w64-mingw32.static qtbase
    

    The default MXE_TARGETS value is i686-w64-mingw32.static.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...