Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qtcreator with cross compiles
I have Mackbook with Qt 5.8 beta 1. I want to compile my project to macOS, Linux and Windows. I installed Window gcc compiler to my macOS usin this script. What I need to do in QtCreator to configure my project for build from macOS to Windows without virtual machine?
This post is deleted!
@shav You need a Qt build created using MinGW compiler you installed. So, first you need to build Qt with that compiler.
Thanks for the replay!
Can you post the link to the documentation where I can find a samples for build Qt with custom compiletor?
In my case I have installed the compiletor to folder /usr/local/Cellar/mingw-w64/4.0.4
I've using this command to configure the build:
./configure -prefix /Volumes/HPDD/Applications/Qt/Qt5.x/5.8/mingw_32 -xplatform win32-g++ -device-option CROSS_COMPILE=/usr/local/Cellar/mingw-w64/4.0.4/bin/i686-w64-mingw32-g++
But this command generate error message:
Checking for valid makespec... executing config test verifyspec + cd /Volumes/HPDD/Applications/Qt/qt-everywhere-opensource-src-5.8.0-beta/qtbase/config.tests/common/verifyspec && /Volumes/HPDD/Applications/Qt/qt-everywhere-opensource-src-5.8.0-beta/qtbase/bin/qmake -qtconf /Volumes/HPDD/Applications/Qt/qt-everywhere-opensource-src-5.8.0-beta/qtbase/bin/qt.conf "CONFIG -= qt deb$ + cd /Volumes/HPDD/Applications/Qt/qt-everywhere-opensource-src-5.8.0-beta/qtbase/config.tests/common/verifyspec && MAKEFLAGS= /usr/bin/make clean && MAKEFLAGS= /usr/bin/make rm -f verifyspec.o /usr/local/Cellar/mingw-w64/4.0.4/bin/i686-w64-mingw32-g++ -c -pipe -fno-keep-inline-dllexport -O2 -Wall -Wextra -fno-rtti -fexceptions -mthreads -DUNICODE -DQT_NO_DYNAMIC_CAST -I. -I/Volumes/HPDD/Applications/Qt/qt-everywhere-opensource-src-5.8.0-beta/qtbase/mkspecs/win32-g++ -o verifyspec.o verifyspec.cpp /usr/local/Cellar/mingw-w64/4.0.4/bin/i686-w64-mingw32-g++ -Wl,-s -Wl,-subsystem,console -mthreads -o verifyspec.exe verifyspec.o /usr/local/Cellar/mingw-w64/4.0.4/lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/bin/ld: cannot find -lstdc++ /usr/local/Cellar/mingw-w64/4.0.4/lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/bin/ld: cannot find -lgcc /usr/local/Cellar/mingw-w64/4.0.4/lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/bin/ld: cannot find -lgcc collect2: error: ld returned 1 exit status make: *** [verifyspec.exe] Error 1
As I understand I need to set path to library. How I can set this path?
Thanks for the any help.
@shav To be honest: it would be MUCH easier to build on Windows instead of doing cross compilation on MacOS! Especially if your application becomes more complex and starts to use other libraries. Is there a reason why you cannot use a Windows machine (can be a virtual machine) to build for Windows?
I never tried to cross compile for Windows.
Thanks for the reply!
Yes, I have a virtual machine with Windows and I've installed Qt from package to virtual machine. It's works fine! But I want to learn how to use cross compilation with Qt. I think this is need for me as a new skill :)
Any way I'll continue research for solve my problem with this. Thanks for the help!
While it's a great idea to learn how to cross compile it's also very complex.
You often end up with complete build of the framework for each platform.
And once you get it up and running, it breaks kinda easy if you update the OS or the toolchain.
For that reason, using virtual machines is just more effective and if I hire someone new, I can just
give him a copy and it takes minutes to get up and running and not days.
If I damage it, it can fast be restored.
As a real skill though. Being able to setup cross compiling for Arm is a very good thing.
Good luck :)
shav last edited by shav
I'm found the solution of my problem with cross compilation on OS X. The solution is MXE.
Here is script to install:
#install all need tools using home brew. brew install autoconf automake coreutils gdk-pixbuf gettext gnu-sed gnu-tar intltool libtool p7zip wget xz #install scons tool ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null brew install scons mkdir mxe && cd mxe #install mxe git clone https://github.com/mxe/mxe.git . export PATH=$PATH:/usr/local/opt/gettext/bin #install qt 5 for windows 32 bit by default. make EXCLUDE_PKGS='gsoap' qt5
After install you will need to add compiler to QtCreator. Also add path to MXE bin folder:
Now I test it on my project and let you now about results.