Search code examples
ubuntudebianmingw-w64

Debian - g++-mingw-w64 not found


I'm trying to compile a Windows cpp program on Linux Debian based and I have wingw-w64 installed but on the console it doesn't see it.. How can I solve the problem?

When I try this I get:

└─$ g++-mingw-w64                     
g++-mingw-w64: command not found

How can I solve this problem?

mingw-w32 works good.

Thank you!


Solution

  • That doesn't look like the right file name.

    The correct file name will start with the triplet <arch>-w64-mingw32 where <arch> is the processor architecture: i686 for x86, x86_64 for x64 (maybe even aarch64 for Windows on ARM).

    Use:

    • Windows 32-bit
      • i686-w64-mingw32-gcc (C)
      • i686-w64-mingw32-g++ (C++)
    • Windows 64-bit
      • x86_64-w64-mingw32-gcc (C)
      • x86_64-w64-mingw32-g++ (C++)

    Tip:

    To check what platform the generated output (.exe/.dll) runs on use the file command. For example:

    echo "int main () { return 0; }" | x86_64-w64-mingw32-gcc -xc - -o test.exe
    file test.exe
    

    which returns:

    test.exe: PE32+ executable (console) x86-64, for MS Windows