How can I compile C++ code with MSYS2 that doesn't depend on the msys iibraries?

I heard that MSYS2 was more powerful than regular MinGW so I installed that and uninstalled MinGW. However when I compile with g++ it seems to depend on MSYS-specific libraries. How can I compile to native windows executables?
Grain of salt here; I haven't used a Windows machine for about 5 years now, and haven't ever used msys2.
If I remember correctly, even code built in Visual Studio will require you to ship your project with .dll object files due to dependencies even between different versions of VSC++. I remember having to track down the correct dll on my XP so that my code would run on another person's XP, not sure if it's easier now with the current version.
So as far as I know, no, you need those .dll files because you are using a different compiler than what was actually used to build your system...

And in a couple of minutes someone is going to prove me wrong on that because of my bad memory, grain of salt, right? ...

Maybe this confirms what I'm saying:
https://docs.microsoft.com/en-us/cpp/windows/determining-which-dlls-to-redistribute?view=msvc-160

Edit: I think I might have overthought the prompt. Are you asking about dependencies when distributing your code to other computers? I think we need you to clarify what exactly is going wrong. If it's how to get gcc working, then this video should help: https://www.youtube.com/watch?v=3TAcdcaEWN0
Last edited on
You are using the MSYS2 compiler, so it will be using MSYS-specific libraries for the needed run-time functionality.

How can I compile to native windows executables?

Either use Visual Studio for your compiler and/or use static linking of the run-time libraries. The file size will expand a lot with the static linking.
Topic archived. No new replies allowed.