Unsolved cross compilation-Linux -> Win
-
I have a dual boot system running Win10_64 and Linux Mint. I finally got Win to run Qt. I've tested a few things with a trivial project from the tutorials. I can write code in Linux and then open the project in Win, add to it and build/run. Then I can go back to Linux and copy the modified files into my existing project and compile/run with the changes implemented on Win. Seems to work ok both ways. Now what I'm really wanting to figure out is how to do all the coding on Linux and output executable files for both Linux and Windows. I'd appreciate a good step by step, but I'm also willing to do my homework if someone can point me in the right direction. There's so much documentation for Qt that I'm a little lost trying to find my way around. I don't know if it matters or not, but the Win Qt setup is using MSVC 2015 for the compiler. I tried MinGW, but couldn't get it to work. Thanks for any help.
-
Hi,
You can't mix and match C++ libraries compiled with different compilers on Windows, the only exception currently being VS2017 that is compatible with VS2015.
So if you'd like to get started with Qt + MinGW, don't forget to install the compiler packages.
-
@SGaist "how to do all the coding on Linux and output executable files for both Linux and Windows" - you mean you want to build for Windows on Linux?
While this is theoretically possible you should forget about it - it is much easier to build on Windows for Windows. -
SGaist, I never had any luck with MinGW in Qt. It would show MinGW as being detected, but wouldn't allow me to select it as the compiler for my project after a build error of "no compiler found". It took me several tries to finally get a working environment on Win as described in the OP.
jsulm, I could do that, but it's not what I was going for. I read an article about how Qt can be used to output applications for other platforms and even create an installer that includes dynamically linked libraries if necessary. That's what I want to learn how to do.
-
Often when people have trouble with MinGW is when they install their own version rather than the one coming with the installer. Did you experience something similar ?
As for the installer, the QtIF allows to build one installer per platform. You can't have one executable that will work on all OS since they are all different. So a native build is still necessary. Even though you could use the MinGW cross-compiler on Linux to generate a Windows executable it can be pretty involved and also you can't make use of native API if needed by your application., You should rather do native compilation for the platform you want support. Visual Machines are now pretty easy to setup for that kind of tasks.
-
Hi
Cross Compiling from window to linux or from linux to windows is a huge pain in the time table.
Installing a virtual machine and setup Qt might take 1-2 hours at max.
Cross Compiling ALL of the tool chain ( u can get predefined sometimes for mingw ) + Qt to be able to output a windows .exe in linux is very complicated
and while possible its not a nice solution as you will need to do it all over again if upgrading Qt etc.
Also u cannot debug the app in linux..
Also it took 3 days to get it running and it still had issues with Qt. And he was a toolchain expert. I gave up since
there are no real good tuts or info. Its not used by many due to all the limitations.http://stackoverflow.com/questions/2033997/how-to-compile-for-windows-on-linux-with-gcc-g
So yes, its possible but it not really useful for real development as i see it and very time consuming to get running and even worse to maintain as not
widely used so setting up a wm is so much more productive and functional. Also hard drives are cheap so in time/cost calculations its a bad solution to try
to setup cross compile.I
-
@mrjj
http://mxe.cc works but is really pain (you know where ;) )... and it does static building -
"Often when people have trouble with MinGW is when they install their own version rather than the one coming with the installer. Did you experience something similar ?"
Are you talking about the MinGW installer or the Qt installer? I tried the online installer for MinGW and also downloaded a zip file that looks to be just a folder containing all the tools and libraries. I never got to try the zip version because at about the same time I found the MSVC Build Tools 2015 and it worked, although there was an issue with that too. I had to completely uninstall Visual Studio 2017 and any runtimes from 2015 on and delete the folders before MSVC Build Tools would install properly and work with Qt.
-
@cejohnsonsr said in cross compilation-Linux -> Win:
Are you talking about the MinGW installer or the Qt installer?
The Qt installer. The mingw Qt precompiled packet comes with
mingw compiler and debugger. ( UNLIKE the vs201X ones)Often if u install some OTHER mingw from other source it can give issues.
-
@mrjj, well that might explain it. I took the installation instructions to mean that I had to install the compiler myself.
-
@cejohnsonsr
Well that is also possible but the issue is that Qt is shared libs. (DLLS)
And to use them with other compiler than used to produce them, stops working very fast.But its possible to install what ever mingw version and compile all Qt with it.
That always works. But if you dont need a special version of mingw ( older/newer) then
just using the included one is far more fun.Also for VS. it must match 100%. So u cant install say have vs 2013 and use Qt for 2015.
Only exception it seem sis that Qt 2015 DOES work with vs2017.