Important: Please read the Qt Code of Conduct -

Cross-compiling to ARM with QtCreator 5.x on Windows

  • I have been using QtCreator 5.x to develop MS-Windows applications, but now need to develop desktop applications on Raspberry Pi2 and BeagleBone Black. I understand that I need ARM libraries and a cross-compiling tool chain.

    In researching how to do this I have encountered lots of articles written about failure or articles that relate to old and deprecated versions and utilities. No success stories apart from using Linux as the development host platform.

    I have managed to get QtCreataor 3.2.1 (Qt 5.3.2) running and developing on the Raspberry Pi-2 (Raspbian/Jessie) but it is too slow for any real work.

    Is it possible to use QtCreator on Windows to develop, compile, deploy and debug desktop applications on Embedded Linux ARM devices? I am currently running Windows 7 64-bit.

    Any tips or suggestions on how to do this are welcome.


  • Yes, it is. The best approach I could find was to compile Qt using the msys2 environment in association with the right cross compiler for the target platform. You should use the configure script not the bat file. After compiling, just add this new build manually to Qt Creator and it's done.

    Here's an example of a configuration I have for an ARM Linux:

    ./configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -prefix C:/Qt/5.5/arm -no-icu -plugin-sql-sqlite -nomake examples -no-compile-examples -nomake tests -openssl -release -v -qreal float -skip qtwebkit -qt-zlib -skip translations -eglfs -shared -force-debug-info -opengl

    Some libraries might be missing on the host machine. In that case, you should copy them from the target system to your computer and add their paths to the command line above. For example:

    -L C:/sysroot/usr/lib -L C:/sysroot/usr/local/lib

  • @Leonardo Thank you for your reply Leonardo. Sorry, but I'm afraid that a lot of it went over my head.

    If I understand correctly, the only way is to compile QtCreator from source on the host (Windows 7) system?

    Since my Pi-2 had Qt 5.3.2 working, I downloaded "qt-opensource-windows-x86-android-5.3.2.exe" from Qt. I thought that since this Qt/Windows install already had support for ARM-7, it would only require a cross-compiler installing and configuring, such as Yagarto or GCC ARM. Is this completely naive of me?

    If I attempt your approach, then what compiler do you think I should I use on the host? Visual Studio Express? MIN GW?

    Thank you.

  • Qt and QtCreator are different. QtCreator is the IDE. Qt is the set of tools and libraries, the framework. Qt has components that should run on the host machine (qmake, moc, etc) and components that should run on the target machine (libraries mostly).

    You can see on the configuration line above that we have two parameters: -platform and -xplaform. The former specifies the host machine, and the latter the target machine. You can't use the android build for raspberry. Both are ARM, but that's all. Other than that, they have few things in common.

    So you already have QtCreator for Windows. It's the same whatever system you're targeting. You only need to compile Qt. First of all, you need a cross compiler. I have no experience with Raspberry Pi, but I would say this one should do it:

    Add it to your PATH. For the host you can use either mingw or visual studio. It's up to you. After that try to compile Qt using the msys2 environment.

    ./configure -platform win32-g++ -xplatform linux-arm-gnueabihf-g++ -device linux-rasp-pi2-g++ ...

    -device should account for board specific settings. Qt has no mkspec for "linux-arm-gnueabihf-g++". Just duplicate the "linux-arm-gnueabi-g++" one and add the "hf" everywhere.

    Indeed there are very few resources out there about Qt and cross compiling for Windows. It took me quite some time to understand it. Maybe you should get more familiar with the usual Qt compilation process first and only then try cross compiling.

  • @Leonardo When you explained that I cannot use Qt ARM for Raspberry Pi a light was turned on at the end of the tunnel. Of course it isn't and I see that now.

    I have done some background reading and now believe that I have a better understanding, although there are still some gaps.

    So, I need Qt creator on the development host (Windows). This can be downloaded.

    I still don't quit understand where the MSYS2 comes in. I understand that this is a "Linux" type environment that runs on top of Windows. I understand that this will provide the minimum directory structure for compiling Qt.

    Assuming I compile the Qt development libraries, does this remain in MSYS2 or is it moved into the C:\Qt directory?

    Are you saying that I have to cross-compile Qt for the Raspberry Pi-2?

    I just don't understand what Qt I need to compile where.

    Sorry to be a pain. I promise to share this information once I get there.

  • Hi. I recommend the msys2 environment because the "configure.bat" that is used on Windows doesn't know how to compile to any target other than Windows. Therefore we need to use the "configure" shell script, that's used on Linux. msys2 was the best tool capable of running it that I could find for this purpose. It's also integrated with the mingw-w64 compiler, so you just need to get a cross compiler and you have all you need.

    You need to cross-compile Qt's source code. See here:

  • No success. I have managed to overcome a number of issues, but I am stuck with the current problem and I am not sure if my overall approach is correct?

    I started with a virgin install of Windows 7 (service pack 1) 64-bit, with all updates performed. This is hosted on a 4GHz Intel i7 system with 16GB RAM and 1TB 7200RPM hard drive.

    Qt Creator
    Qt Creator 5.5.1 was downloaded, installed and a trivial project completed to test the install. It is running 32-bit because I opted for the MINGW version.


    MSYS2 was downloaded and installed. I chose 64-bit since I am using Windows 7 64-bit. installation/


    Raspberry Pi Toolchain
    Just as you recommended I downloaded and installed the toolchain for Raspberry Pi.


    I made sure that the PATH environment variable was set and checked that “arm-linux-gnueabihf-g++” was executable within MSYS2.

    Qt 5.5.1
    Then I downloaded the Qt 5.5.1 source. Since I was using Windows 7 I downloaded the ZIP version and used 7Zip to extract the files. These were extracted to C:\qtsource being a name consisting of simple ASCII characters.

    I then navigated to C:\qtsource\qtbase\mkspecs and copied the \linux-arm-gnueabi-g++ directory to \linux-arm-gnueabihf-g++. I then edited the qmake.conf file to add “hf” (hard float) to all the named files. On checking with the Raspberry Pi toolchain I noticed that the executables within C:\SysGCC\Raspberry\bin used the name format “arm-linux-gnueabihf-” so I renamed the named files to this name format. Eg:

    QMAKE_CC = arm-linux-gnueabihf-gcc

    So now time to configure and make. I launched a MSYS2 Shell and copied a modified version of your example ./configure command line in. At first I encountered an (e=2) file not found error. After a lot of scratching around I realised that the g++ was not being found. In the Raspberry Pi toolchain bin directory I copied arm-linux-gnueabihf-g++.exe to g++.exe and tried again.

    This time there was credible activity, but terminated with:

    In file included from C:/qtsource/qtbase/qmake/generators/makefiledeps.cpp:40:0:
    C:/qtsource/qtbase/mkspecs/win32-g++/qplatformdefs.h:47:19: fatal error: tchar.h: No such file or directory
    #include <tchar.h>
    compilation terminated.
    make: *** [makefiledeps.o] Error 1

  • You're almost there! It's just that the last step is wrong. You should not have copied arm-linux-gnueabihf-g++.exe to g++.exe . As I said before, some tools are build for Windows and the libraries are build for Linux. Therefore, we need two compilers. If g++ is missing, it means that you're missing MinGW-w64 in your msys2 environment. First of all, check whether you have a shortcut named "MinGW-w64 Win64 Shell" in your start menu. If you do, that's the one you should be using. If you don't, you should install the package:

    pacman -S mingw-w64-x86_64-gcc

  • Ah!

    So the Raspberry Pi toolchain is used by QtCreator to build my projects for deployment on the Raspberry Pi device, whereas MinGW is used to build the Qt library for use within QtCreator on Windows?

    In which case don't I need the MinGW-32 compiler environment, since I am using QtCreator MinGW 32-bit?

    I deleted the g++.exe as you suggested and installed the MinGW-64 package into MSYS2. There was encouraging extivity but again it failed with:

    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: project.o: Relocations in generic ELF (EM: 40)
    project.o: error adding symbols: File in wrong format
    collect2.exe: error: ld returned 1 exit status
    make: *** [../bin/qmake.exe] Error 1

  • I don't get what you said about the compilers, but forget it for now.

    It seems like you have a dirty source tree. That's why you get that error. Delete your "qtsource" directory and extract the zip file again.

  • Thank you.

    So, I deleted the existing C:\qtsource and unpacked a new one. I then duplicated the \linux-arm-gnueabi-g++ directory to \linux-arm-gnueabihf-g++. Then I edited the qmake.conf to add "hf" to the file names.

    I then removed MSYS2 and reinstalled. I used the command you suggested to install MinGW64. I also used the command pacman -S diffutils as I had been getting the error "cmp: Command not found".

    I then run the configure statement:

    ./configure -platform win32-g++ -xplatform linux-arm-gnueabihf-g++ -device linux-rasp-pi2-g++ -prefix C:/Qt/5.5.1/5.5/linux-rasp-pi2 -no-icu -nomake examples -no-compile-examples -nomake tests -openssl -release -v -qreal float -skip qtwebkit -qt-zlib -skip translations -eglfs -shared -force-debug-info -opengl

    There was a lot of activity this time ending in the following error:

    Running configuration tests...
    Failed to process makespec for platform 'devices/linux-rasp-pi2-g++'
    Project ERROR: CROSS_COMPILE needs to be set via -device-option CROSS_COMPILE=<p ath>
    Could not read qmake configuration file C:/qtsource/qtbase/mkspecs/devices/linux -rasp-pi2-g++/qmake.conf.
    Error processing project file: C:\msys64\tmp\empty-file

  • It's getting better. I've never used the "-device" parameter before, actually. Try something like this:

    ./configure -platform win32-g++ -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf-

    By the way, you can build it outside the source tree, so you don't need to delete it every time. Create a folder like C:\qtbuild and call the configure script from it.

    /c/qtbuild> ../qtsource/configure -platform.....

  • Thanks for the tip building outside the source tree.

    Things seem to be going backwards now. I have this tchar.h: No such file or directory error back. I am using a clean C:\qtsource and C:\qtbuild. I have been struggling with this for about an hour.

    I checked and there is a device definition for "linux-rasp-pi2-g++" in C:\qtsource\qtbase\mkspecs\devices.

    The configure statement is this:

    ../qtsource/configure -platform win32-g++ -xplatform linux-arm-gnueabihf-g++ -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -prefix C:/Qt/5.5.1/5.5/linux-rasp-pi2 -no-icu -nomake examples -no-compile-examples -nomake tests -openssl -release -v -qreal float -skip qtwebkit -qt-zlib -skip translations -eglfs -shared -force-debug-info -opengl

    This is the resulting error:

    C:/qtsource/qtbase/mkspecs/win32-g++/qplatformdefs.h:47:19: fatal error: tchar.h: No such file or directory
    #include <tchar.h>
    compilation terminated.
    make: *** [makefiledeps.o] Error 1

  • Oh, I'm sorry. My mistake. You need the whole toolchain. The command line I've posted before was only for gcc. Here:

    pacman -S mingw-w64-x86_64-toolchain

    By the way, now you should remove the -xplatform parameter, as you're using CROSS_COMPILE.

    Don't forget to clear your qtbuild folder, just to be sure.

  • Hi Leonardo. Sorry, I am still getting the same error:

    In file included from C:/qtsource/qtbase/qmake/generators/makefiledeps.cpp:40:0:
    C:/qtsource/qtbase/mkspecs/win32-g++/qplatformdefs.h:47:19: fatal error: tchar.h: No such file or directory
    #include <tchar.h>
    compilation terminated.
    make: *** [makefiledeps.o] Error 1

    I am using this configure statement with -xcompile omitted:

    ../qtsource/configure -platform win32-g++ -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -prefix C:/Qt/5.5.1/5.5/linux-rasp-pi2 -no-icu -nomake examples -no-compile-examples -nomake tests -openssl -release -v -qreal float -skip qtwebkit -qt-zlib -skip translations -eglfs -shared -force-debug-info -opengl

    I installed "all" packages using the pacman command that you suggested. I also deleted and create a new C:\qtbuild directory.

    Edit #1

    I did some digging around and can confirm that tchar.h is located in:


    Edit #2

    After reading more Qt documentation (why don't they date their documentation?), I suspect that this latest error is arising from not having and specifying a SYSROOT. I could be wrong of course. Am I required to have a Raspberry Pi image available on the Windows 7 platform to provide this sysroot? It seems to be a step taken in the instructions for cross-compiling Qt for RaspberryPi2 from Ubuntu.

    I also struggle with is the role of the two toolchains here. There is the MinGW64 hosted within MSYS2. There is also the Win64 toolchain for Raspberry Pi downloaded from SysProgs.


  • Hi JaffaMicroBrain.

    I have the same problem.
    I try to croos compile from windows and it seems that the file tchar.h is missing.
    I've followed this tuto
    but still having the same problem.
    Have you found any solutions to this ?


  • After quite some hours of "fun" I managed to get the (excellent) set of instructions at:

    to work on Windows 10. The trick was to start with a completely clean version of Raspbian, and then to install QT 5.5:

    sudo apt-get install qt5-default

    Note that I didn't also install Qt Creator on the PI.

    If you then follow the instructions to the letter, all will be well.

    I found the UpdateSysroot step painful as my network was having a bad day - rather than synching /opt it will be faster to synch just /opt/vc.

    The make step has taken about 6 hours.

    I had originally started out with more dev stuff installed on the PI and ran into issues with missing header files as you guys have done, but this way worked. Hope it works for you too! Regards, Mike

  • @MikePelton I am struggling to get the cross-compiling working for the past three days. while syncing my PI with the windows PC, I have seen all the paths in the above link you have mentioned, but i could not find the /opt. Could you please suggest me, where can be the problem. I have followed exactly the same steps as in except that my debian jessie was old.

  • Hi All, after years I have same problem. Do you have any solution?

Log in to reply