I am trying to cross compile Hyperion for a 32-bit Windows on a 64-bit Debian linux, but I ran into a few problems in doing so.

First of all, in attempt to install a cross compiler, I installed mingw32 on linux. I am not sure if I installed the correct version or not since there were so much similar packages. Eventually, I locate and read a readme.txt and learn that i686-w64-mingw32-gcc is supposed to be the correct 32-bit Windows C compiler, but there were two versions of i686-w64-mingw32-gcc that might be what I am looking for: i686-w64-mingw32-gcc and i686-w64-mingw32-gcc-win32. So I chose to use i686-w64-mingw32-gcc-win32.

Next, it complaints about not being able to locate cc1plus. A locate of that file led me to /usr/lib/gcc/x86_64-linux-gnu/5/. I went ahead creating a soft link at /usr/bin to /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus.

Afterward, it complaints about missing windows.h. I locate it at /usr/i686-w64-mingw32/include/. After adding -I option to that path to CFLAGS, I got various strange errors. Among them is the one below:

/usr/i686-w64-mingw32/include/_mingw.h:264:2: error: #error Only Win32 target is supported!

Now, I am stuck. I am not sure which step I did wrong. I suspect that it might be the wrong cc1plus I soft linked, but I don't know how to get the right version if that is wrong.


The cc1plus you linked is the normal C++ compiler's, not the Windows cross-compiler's. You should never need to fix GCC's internal components; the cc1plus error indicates something else is wrong.

In your case, you need to install mingw-w64 (apt-get install mingw-w64). This will install a C and C++ cross-compiler for Windows and the appropriate header files and libraries. Then use i686-w64-mingw32 as the target; i686-w64-mingw32-gcc should work fine. (See the README.Debian in /usr/share/doc/gcc-mingw-w64-base for details of the -win32 v. -posix stuff; the defaults should work fine for you.)

  • mingw-w64 is not found when using apt-get as I tried that before using the GUI Package manager. This is where I ran into problems of which packages I needed. I will try to remove the soft link to cc1plus to see if I can install the proper packages to fix that problem.
    – Ice Drake
    Dec 9 '16 at 8:24
  • What version of Debian are you using? Dec 9 '16 at 9:15
  • If you can't install the mingw-w64 package (which suggests there's something very wrong with your apt sources — the package is present in Debian 7 and 8), you can try installing g++-mingw-w64-i686 (that's the 32-bit-only C++ cross-compiler). Dec 9 '16 at 9:19
  • Actually, I make a mistake. I should have said that I have Kali linux, a Debian-based linux, not Debian linux. Your suggestion for trying to install g++-mingw-w64-i686 makes me realized something as well. I was using the wrong compiler the whole time. I kept thinking that I need a C compiler, but in reality, the code was written in C++. After switching my compiler to i686-w64-mingw32-c++-win32, it works flawlessly. Thank you so much. I struggle with this problem for a very long time.
    – Ice Drake
    Dec 9 '16 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.