cross compiling to windows

I was trying to figure out how I can cross compile from linux to windows, I initially noticed that settings.yml said nothing about mingw and so I got a little confused, eventually I found a sample profile which was outdated and used some broken packages like mingw_installer which no longer existed, at the end of the day I was able to get it to work like this. Create the following windows conan profile:

  
[tool_requires]
mingw-w64/8.0.2

[settings]
os=Windows
arch=x86_64
compiler=gcc
compiler.cppstd=17
compiler.version=14
compiler.libcxx=libstdc++11
compiler.threads=posix
build_type=Release

  

Then navigate to your project directory and run

  
    conan install . -pr:b=default -pr:h=windows --build=missing -of=build_windows
  
-of specifies the root output folder for generated and build files, if you don't specify this it will by default overwrite stuff in your current build making the subsequent cmake calls fail

From there it successfully built my required packages using mingw and I used cmake --preset conan-release and then cmake --build --preset conan-release and then it compiled, I got an unrelated error during my first go with cmake building because I forgot to set the cppstd to the same that of which I built the linux version with, so don't forget things like that.


edit this page