std::mutex missing when building Qt app with MXE gcc

895 views Asked by At

I'm attempting to get a Qt application to build from the command line under linux targetted for windows. I've used mxe to build a toolchain for targetting windows but my build fails whinging about various thread related bits. mxe built with winpthreads and I know the Qt project will build on windows itself from inside of creator, using the pre-packaged mingw compiler. I'm successfully building using my ARM Linux cross compiler, so I just want to get windows done the same. I'm trying to get a one line build on a build server or from Jenkins for all my targets.

I'm guessing I'm missing something that I need to pass to mxe when doing the cross toolchain build or alternatively missing something I need to pass to qmake for this build to succeed.

2

There are 2 answers

0
Joe On

The issue is with the default MXE build of GCC using win32 threads as opposed to mingws pthreads implementation.

Edit src/gcc.mk and ensure that winpthreads is added to the $(PKG)_DEPS list and then change the configure line so that --enable-threads=win32 becomes --enable-threads=posix.

Then re-make winpthreads and gcc. Note that there is a circular dependency here, you need to build gcc with win32 threads (the default) first THEN remake with winpthreads.

Thanks to Andreia Gaita for this - http://blog.worldofcoding.com/2014/05/cross-compiling-c11-without-going-madder.html

0
Velkan On

POSIX configuration was added to MXE (Building pthreads inline with gcc and enable optional posix threads in libgcc).

For example, to build qt with that (x64, shared, posix threads):

make MXE_TARGETS='x86_64-w64-mingw32.shared.posix' qt