Windows 10 (32-bit): MinGW-w64 doesnt work - c++

I've tried to compile my source files using minGW-w64, because of new C++14 standard but when i try to compile i got this error even all things and setup is allright i guess:
Execution of 'g++.exe -c C:\Users\Denis\Desktop\isocpp.cpp -o C:\Users\Denis\Desktop\isocpp.o' in 'C:\Users\Denis\Desktop' failed.
MinGW-w64 Screenshot
My PC version is 32bit, from the official site i was notified that MinGW-w64 works for 64-32bit.

There are two distinctions to make here:
Whether gcc.exe is a 32-bit binary or a 64-bit binary
Whether that binary will generate programs that target 32-bit or 64-bit
mingw-w64 supports all four possible combinations here. But it sounds like you have downloaded a 64-bit binary. 32-bit Windows cannot run 64-bit binaries.
To fix this, use the official installer (warning:Sourceforge, although it is not hosted anywhere else so far as I know), or look out when downloading prepackaged builds.

Related

I am trying to install MinGW but it's always failing to install

I am trying to install MinGW but it's always failing to install.
on windows 7
link of the program:
https://sourceforge.net/projects/mingw/files/latest/download
Tar zips are not generally for windows users the downlink should be a windows installer mingw-get-setup.EXE thus (not a GnuZip)
Also if your trying to unpack 32bit collections the question is which architecture do you need, certainly 32.exe will run on 64, but 64.exe will NOT work on 32.
Current build is 32bit "Although (currently) offering only a 32-bit compiler suite, all of MinGW's software will execute on the 64bit Windows platforms."
get it from official https://osdn.net/projects/mingw/releases/
latest link I got was
https://osdn.net/frs/redir.php?m=liquid&f=mingw%2F68260%2Fmingw-get-0.6.3-mingw32-pre-20170905-1-bin.zip
once you have a valid windows .zip file, right click to "extract" then the exe should be in the bin folder.
Then it's just you on your own, and the myriad of instructions from google.
MinGW is a compiler generating files for the Windows platform, but MinGW itself can also be run on other platforms (like Linux for example).
What you need is are Windows binaries of MinGW.
But MinGW is a bit outdated and only supports 32-bit Windows.
I would really recommend using MinGW-w64.
Standalone build of MinGW-w64 for Windows (both 32-bit and 64-bit) are available at https://winlibs.com/ just download the archive and extract it. Then all the tools you need will be in the mingw32/bin or mingw64/bin folder.
If you're not very familiar with command line tools you should really use an IDE. There are some instructions on https://winlibs.com/ on how to use MinGW-w64 with Code::Blocks.
If on the other hand you are very familiar with command line or the Linux shell you should take a look at MSYS2 which also allows installing MinGW-w64 with it's pacman tool.

I'm trying to relearn GCC C or C++ compiling help please

TWO QUESTIONS HERE:
according to this in another post elsewhere --
"had to compile a 32-bit application using GNU gcc on the 64-bit version of Linux.
Luckily, gcc man page directed me to the '-m32' and '-m64' options. These options generate code for 32-bit or 64-bit environments, respectively.
The 32-bit environment sets int, long and pointer to 32 bits and generates code that runs on any i386 system.
The 64-bit environment sets int to 32 bits and long and pointer to 64 bits and generates code for AMD's x86-64 architecture."
I have this C program I modified adding features to it that I wanted and needed -- now that I have moved from a 32 bit Linux to a 64 Bit linux this program no longer works with 64 bit Linux.
before I get to ahead of myself --
Question: do I now have to re-compile it as a 64 bit program using m64 to get it to work?
when I recompiling it with the -m32 I get an error as well.
using Xlib.h
/usr/include/X11/Xlib.h:38:23: fatal error: sys/types.h: No such file or directory
I have already googled into this error -- looking at several posts and made sure I have build-essential installed, and it is.
and xlib.h are installed too.
is this looking for "sys/types.h" referencing the X11 or somewhere else?
I have no idea how to fix this problem either.
Question: do I now have to re-compile it as a 64 bit program using m64 to get it to work?
If you already have a 32-bit executable, you should be able to run it on a 64-bit Linux. Provided you have the required 32-bit system libraries installed.
when I recompiling it with the -m32 I get an error as well.
That most likely means you do not have 32-bit development packages installed.

Using the mingw-w64 fork with the standard msys

I want to use GNU GCC on Windows so I've downloaded mingw, but the x86_64 fork.
Instead of using cmd, I want to use msys, but msys is designed for the standard 32bits version of minGW. I've moved the bin, lib, libexec etc folders from minGW-64 to the msys folder, combining folder if necessary.
I didn't need to modify my PATH and msys console recognize the gcc executables.
I'm wondering what could be the drawbacks (if any) of using a msys prepared for the 32bits version of minGW. I'm afraid that may be using a not optimized environment and that I could discover that at link time I may be linking 32bits symbols or using 32bits symbols at runtime instead of being full 64.
There a bit of confusing terminology here:
The mingw-w64 project worked on getting 64-bit support on Windows. However, the result of their efforts is both a 32-bit version and a 64-bit version. You should not be using the classic mingw at all, since it is horribly outdated.

How to compile C++ programs in codeblocks for 32bit computers with the dual targets MinGw compiler [duplicate]

I've downloaded MinGW with mingw-get-inst, and now I've noticed that it cannot compile for x64.
So is there any 32-bit binary version of the MinGW compiler that can both compile for 32-bit Windows and also for 64-bit Windows?
I don't want a 64-bit version that can generate 32-bit code, since I want the compiler to also run on 32-bit Windows, and I'm only looking for precompiled binaries here, not source files, since I've spent countless hours compiling GCC and failing, and I've given up for a while. :(
AFAIK mingw targets either 32 bit windows or 64 bit windows, but not both, so you would need two installs. And the latter is still considered beta.
For you what you want is either mingw-w64-bin_i686-mingw or mingw-w64-bin_i686-cygwin if you want to compile for windows 64. For win32, just use what you get with mingw-get-inst.
See http://sourceforge.net/apps/trac/mingw-w64/wiki/download%20filename%20structure for an explanation of file names.
I realize this is an old question. However it's linked to the many times the question has been repeated.
I have found, after lots of research that, by now, years later, both compilers are commonly installed by default when installing mingw from your repository (i.e. synaptic).
You can check and verify by running Linux's locate command:
$ locate -r "mingw32.*[cg]++$"
On my Ubuntu (13.10) install I have by default the following compilers to choose from... found by issuing the locate command.
/usr/bin/amd64-mingw32msvc-c++
/usr/bin/amd64-mingw32msvc-g++
/usr/bin/i586-mingw32msvc-c++
/usr/bin/i586-mingw32msvc-g++
/usr/bin/i686-w64-mingw32-c++
/usr/bin/i686-w64-mingw32-g++
/usr/bin/x86_64-w64-mingw32-c++
/usr/bin/x86_64-w64-mingw32-g++
Finally, the least you'd have to do on many systems is run:
$ sudo apt-get install gcc-mingw32
I hope the many links to this page can spare a lot of programmers some search time.
for you situation, you can download multilib (include lib32 and lib64) version for Mingw64:
Multilib Toolchains(Targetting Win32 and Win64)
By default it is compiled for 64bit.You can add -m32 flag to compile for 32bit program.
But sadly,no gdb provided,you ought to add it manually.
Because according to mingw-64's todo list, gcc multilib version is done,but gdb
multilib version is still in progress,you could use it maybe in the future.
Support of multilib build in configure and in gcc. Parts are already present in gcc's 4.5 version by using target triplet -w64-mingw32.
gdb -- Native support is present, but some features like multi-arch support (debugging 32-bit and 64-bit by one gdb) are still missing features.
mingw-64-todo-list

Building zlib libz.a for 32 bit

I am trying to compile a 32-bit version (MinGW) of a program I wrote using zlib. Until now, I've never has to compile for 32-bit so the version of zlib I compiled from source (libz.a) is 64-bit. I tried to rerun the makefile in the zlib-1.2.5 directory but it only compiles a 64bit version of libz.a.
I can't seem to find an option to build 32-bit.
Does anyone know how to do this?
Thanks!
Jeffrey Kevin Pry
Checking the configure file, you can see some env.
On 64bit debian, following command line will build the 32bit version of libz
CFLAGS=-m32 ./configure
It turns out I had to get the 32bit version of MinGW and compile it with that. I was using MinGW64.
Using CFLAGS=-32 won't do it for me, configure script still shouts out telling me to use win32/Makefile.gcc instead all the time.
The recent version of zlib is 1.2.11, so it should be minimal gap of difference up until today. Without any context on system, the following might be useful for other users facing this similar problem these days.
I cross compile on Linux (Ubuntu 18.04), and target 32-bit version of zlib to be produced. What I did is as follows.
./configure (this is just to let us have required file to building process, we will be using different Makefile though)
Modify win32/Makefile.gcc for its PREFIX=i686-w64-mingw32- (for 64-bit you change it to PREFIX=x86_64-w64-mingw32-.
make -fwin32/Makefile.gcc
Install to your desire location via make install -fwin32/Makefile.gcc SHARED_MODE=1 INCLUDE_PATH=/tmp/zlib-win32/include LIBRARY_PATH=/tmp/zlib-win32/lib BINARY_PATH=/tmp/zlib-win32/bin. Notice that you need to specify INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH. BINARY_PATH will contains result .dll file.