Linux-based c++ Qt program to run on Windows

Asked

Viewed 790 times

6

People wanted to know if there is any way and if there is what, to basically create an executable ,of a GUI program made in Qt, for Windows being that I am using Linux.

  • 1

    Guy Voce can use mono or even gcc itself and only compile

  • I compiled here by Qtcreator generated a executable, but only runs on linux as you would expect when I compiled on linux. What I wanted was to create a . exe for windows on linux.

  • This is not very simple, because if you use external libraries you should do the port too, now if it is simple project, get it save the project in QT linux, then open the project in QT in Windows and Compile it.

2 answers

6


There is an open source project called MXE, Minimalist/Mingw cross enviroment. It starts from the source code of several libraries and produces own versions for compilation for Windows, on Linux. Use is very simple, do:

git clone https://github.com/mxe/mxe
cd mxe
make qt5

This will take some time, but it only needs to be done once. Then go to an empty folder where you want to produce the compiled project for Windows, run the following:

/pasta-onde-esta-o-mxe/usr/i686-w64-mingw32.static/qt5/bin/qmake pasta-do-seu-projeto-qt

This will produce a Makefile already configured for mxe. Now extend your PATH to contain the MXE compiler path, and run the make

PATH=$PATH:/pasta-onde-esta-o-mxe/usr/bin
make

The result will be a file .exe. You can even execute him with the wine!

1

This is already done for other platforms and is called cross-compilation (cross-compiling). It’s how apps developed on Windows and Linux are compiled for Android. I’ve never really seen anyone doing cross-compiling Linux -> Windows, but it may be perfectly possible - only you will have to look for how to configure it. You can start by looking for cross-compiling from Linux to Windows and see if something helps you.

(I know it’s kind of a weak response, but I couldn’t write it all down as one comment)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.