Leandro
Leandro

Reputation: 259

Cross compile modern C++ from Linux to Windows

I have some modern C++ sources (C++17, say) and I have no problem compiling complex source base on Linux for Linux 32/64, and on Windows for Windows 32/64 using mingw-w64 (from msys2).

Now I want to cross compile for Windows on Linux, to avoid using a virtual machine just to compile.

So I tried installing mingw-w64 from the Ubuntu repository, but it was compiled with --enable-threads=win32, which is not compatible with std::mutex, for instance, from C++11.

I wasn't able to compile mingw-w64-v7 from source (it only compiles a bunch of libraries and not the compiler itself), I wasn't able to get a single binary already compiled for Linux 64bits either.

What is the way to go to setup a cross compiling toolchain that compiles modern C++ from Linux to get Windows 32 and 64 bits executables?

Upvotes: 1

Views: 6096

Answers (1)

David Macek
David Macek

Reputation: 917

My Ubuntu 18.04 has a POSIX-threaded mingw-w64 toolchain as well. Try update-alternatives --list x86_64-w64-mingw32-g++.

Upvotes: 2

Related Questions