Thread: GCC Missing MinGW-w64?

  1. #1
    Registered User
    Join Date
    Oct 2021
    Posts
    4

    GCC Missing MinGW-w64?

    Hi, I'm using Ubuntu 20.04 on Windows WSL2.

    During a compilation of a program using gcc under Ubuntu (wsl2), I received the error "unrecognized command line option -municode".

    I googled, and it seems like I need mingw-w64 in order for gcc to recognize the option "-municode".

    My gcc is version 9.3. In addition, the command "gcc -dumpmachine" responds with "x86_64-linux-gnu".

    If this means gcc 9.3 doesn't already come with mingw-w64, how would I go about adding mingw-w64 to gcc?

    Alternatively, if someone could clarify the relationship between gcc and mingw-w64, that might help me think of the right queries for google.

    (Lastly, I tried "sudo apt install g++-ming-w64-i686", but I get the error "Unable to locate package")
    Last edited by programming; 10-27-2021 at 11:43 PM.

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,628
    During a compilation of a program ...
    What program? Give a link.

    I googled, ...
    What did you google? Give a link to the results that led you to your conclusion.

    I don't think mingw should be needed if you are using wsl and ubuntu.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    mingw-w64 is what you use if you want to use gcc within windows itself.

    If you're inside wsl2, then you have a real Linux OS and can just use the regular gcc without any further faffing about.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Oct 2021
    Posts
    4
    Quote Originally Posted by Salem View Post
    mingw-w64 is what you use if you want to use gcc within windows itself.

    If you're inside wsl2, then you have a real Linux OS and can just use the regular gcc without any further faffing about.
    Yeah I think I asked quite illiterate a question . But just to be sure, why does Debian and Ubuntu have packages on mingw-w64, such as the one noted here: Debian -- Details of package g++-mingw-w64-i686 in stretch or here Ubuntu – Details of package gcc-mingw-w64-x86-64 in bionic .

    Specifically, I didn't understand what the following Debian page statement meant: "This package contains the C++ compiler, supporting cross-compiling to 32-bit MinGW-w64 targets". Could I possibly leverage this package then to overcome errors met by the regular Ubuntu GCC?

    Lastly, if a source file was meant to be compiled using mingw-w64 under windows, does that mean I shouldn't expect to be able to compile it using GCC under WSL linux? For example, I even saw GCC in WSL Ubuntu report header file not found for source statements like "#include <windows.h>".
    Last edited by programming; 10-28-2021 at 02:28 AM.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    The key phrase there is "cross-compiler".

    > This package contains the C++ compiler, supporting cross-compiling to 32-bit MinGW-w64 targets".
    The compiler runs on Linux, but the code it produces runs on Windows.

    > Could I possibly leverage this package then to overcome errors met by the regular Ubuntu GCC?
    Such as?


    > For example, I even saw GCC in WSL Ubuntu report header file not found for source statements like "#include <windows.h>".
    You'd be better off downloading the real mingw into Windows, then compiling your code dependent on windows.h directly in windows.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Oct 2021
    Posts
    4
    Quote Originally Posted by Salem View Post
    The key phrase there is "cross-compiler".
    > Could I possibly leverage this package then to overcome errors met by the regular Ubuntu GCC?
    Such as?


    > For example, I even saw GCC in WSL Ubuntu report header file not found for source statements like "#include <windows.h>".
    You'd be better off downloading the real mingw into Windows, then compiling your code dependent on windows.h directly in windows.
    Thanks very much for the clarifications.

    As for errors, I just meant the error of "unrecognized command line option -municode". However, since "-municode" is an option/flag unique to MinGW, I probably should have never expected GCC from WSL Ubuntu to recognize it.

    Finally, if I were to insist on compiling code dependent on windows.h in wsl ubuntu, would there be tutorials for this? I googled "cross compiling sources that use windows.h", but I've yet to open every link, especially the youtube links that seem relevant.

    On the other hand, the question above is really just for future reference, for judging how difficult an endeavor cross compiling would be. I'm quite ready to just use mingw-w64 on windows
    Last edited by programming; 10-28-2021 at 03:41 AM.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Most people get up to speed working with native compilers first (the code runs on the same machine as the compiler).

    Cross-compilers are a whole new level of complexity.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Oct 2021
    Posts
    4
    In the end, I was able to cross-compile, and since none of the youtube videos helped, I thought I'd post here what finally made my compilation possible:

    (1) Change all file header names to lower case. For example, "#include <Windows.h>" ought to be "#include <windows.h>". The cross-compiler was then able to find the windows header files.

    (2) Use i686-w64-mingw32-gcc instead of x86_64-w64-mingw32-gcc as the cross-compiler. This solved a bunch of incompatible library file errors.
    Last edited by programming; 10-28-2021 at 08:21 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. trying to get MinGW
    By c_weed in forum Tech Board
    Replies: 19
    Last Post: 09-28-2010, 01:26 AM
  2. SDL and mingw. Please help.
    By Erin100280 in forum C++ Programming
    Replies: 2
    Last Post: 08-15-2010, 09:26 PM
  3. mingw
    By manzoor in forum C++ Programming
    Replies: 12
    Last Post: 02-08-2008, 10:21 AM
  4. GCJ & GCC, MingW
    By @nthony in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 09-12-2007, 03:23 AM
  5. mingw help
    By DarkDot in forum Tech Board
    Replies: 17
    Last Post: 04-16-2007, 11:25 PM

Tags for this Thread