How to compile C/C++ for Windows 32 using MinGW? - gcc

I can compile C/C++ code using MinGW for Windows 64-bit.
But how can I compile C/C++ code using MinGW for Windows 32-bit?
Do I need to install 32-bit version of MinGW? If I do, where can I download it?
But as far as I know, mingw-w64 for win32 and win64, or not?
Hope for your help!

MinGW-w64 exists for both 32-bit and 64-bit Windows.
My personal build at http://winlibs.com/ provides separate standalone downloads for 32-bit and 64-bit Windows.
Please see the site for instructions on how to use. It also includes instructions on how to configure Code::Blocks IDE to have both compilers available.

Related

Can Lazarus 64-bit for Windows compile to 64-bit for Windows?

I downloaded, what i thought, would be the 64-bit version of Lazarus:
Although it downloads a 32-bit build:
And after installing it, the IDE is 32-bits:
And it builds 32-bit binaries:
Changing the targeting options to win64, win64, win64:
Gives an error that Lazarus doesn't support 64-bit:
Reading the somewhat dated Cross compiling Wiki page gives the instructions on how to make the 64-bit Lazarus work on 64-bit machines:
From win32 to win64
If you are compiling the 2.1.1 or greater branch of fpc you can just do:
$ make all OS_TARGET=win64 CPU_TARGET=x86_64
and then
$ make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64
which, if you follow, just gives a few thousand errors:
The common suggestion is to abandon the Lazarus IDE, altogether, and use a fork known as CodeTyphoon. Downloading that 500 MB, and installing it, i couldn't find an IDE anywhere:
Which is confusing, because i thought CodeTyphoon was a Pascal Visual Programming Environment.
Before i go on
Before i go randomly stumbling around, downloading gigabytes of stuff, let me just ask straight out:
Can Lazarus 64-bit for Windows compile to 64-bit for Windows?
Is there a 64-bit Lazarus for Windows, that can create 64-bit Windows binaries? Am i missing something, or is that functionality not in there yet?
And if the ability is in there, at least could someone commiserate that my confusion is understandable?
The following is from README.txt files on the SourceForge download pages (http://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2032%20bits/Lazarus%201.2/ and http://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Lazarus%201.2/). However, those readme.txt files are apparently not included in the actual installation.
I have verified that installing the plug-in allows you to build a 64-bit application.
Two things:
there is an add-on for building Win64 applications in the 32-bit Lazarus IDE:
Add-On for building 64bit Windows applications:
lazarus-1.2.0-fpc-2.6.2-cross-x86_64-win64-win32.exe
This file can be installed as add-on to the 32 bit Lazarus IDE (on Systems with Windows 32 or 64 bit), if you wish to develop for
64bit Windows too. If you install this on a 64bit Windows PC together
with the 32 bit Lazarus IDE, you will also able to debug 64 bit
applications.
the link to the 64-bit Lazarus IDE on the Lazarus homepage is incorrect (it points to the Win32 version). The link should be:
http://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Lazarus%201.2/lazarus-1.2.0-fpc-2.6.2-win64.exe/download
If you use the 64-bit IDE you'll need a similar (but different) plugin to build 32-bit binaries.

ILmerge generating only 64bit compatible exe

I am building up my VS2010 project using "any cpu configuration" so that the executable can work for both 32 bit and 64 bit versions.
But after using ILMerge to generate a bundled exe, the resultant exe is only working in 64 bit system and for 32 bit system its showing
This version of output.exe is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.
The ILMerge command used:
C:\BuildTools\ilmerge.exe /out:proj1.exe output.exe 1.dll NLog.dll 2.dll targetplatform:v4 /ndebug
I tried to figure out any option in ILMerge to fix this, but do not find anything useful.
Any help on this will be of great help.
Figured out is the issue with Nlog.dll which was built in 64 bit environment. Fixed after converting it to Any Cpu

What's the difference between Mingw32 and Mingw64 include files?

I used Mingw32 and devc++ IDE to develop my application. I included the lib files and include files of Mingw32 and compiled my application.
My application should run in both 32 bit and 64 bit versions of windows. My doubt here is whether my application run in windows 64 bit system? Even if it works perfectly will there be any problem?
What is the difference between Mingw32 and Mingw64 include files? My ultimate aim is to run my application both in 32-bit and 64-bit windows. What include files should I add and compile?
mingw-w64 is fork of the mingw project.
Generally the mingw-w64 headers are much more complete, they include more recent additions from newer Windows (new SDK headers, function declarations, types, constants, macros), are ready for building 64-bit targets (when used with gcc capable of that).
Note of course that you cannot mix mingw's gcc with mingw-w64 headers or vice versa. You have to use complete toolchain from one or the other. I don't know how easy it is to switch toolchain in the devc++ (I don't use it).

Link GCC libraries statically (libgcc and libstdc) on Windows

I am using Mingw environment, GCC compiler and Code::Blocks IDE to create an application that is supposed to work on different Windows versions, without the need of installing any other software. So, I am using the last version of GCC.
I have created the EXE on a Windows 7 and it works perfectly. I moved it on a Windows XP (recently installed, no .NET, no C++ redistributable, no gcc dlls and it asked me for the libgcc_s_dw2-1.dll and for the libstdc++-6.dll. They couldn't be found on the XP computer. With an older version of GCC this didn't happen.
So, I copied those two libraries inside the same folder as the executable. Now, it also worked on the XP.
What I would like is to link both libraries statically. I added the -static option to GCC but it looks like I don't have the static libraries, only the dynamic ones, so I wonder if somebody can tell me where can I download them from and how would I link them.
Thanks so much!

QtCreator for windows: is it possible to build 64 bit .exe?

Is it any way in QtCreator for windows to build a 64-bit executable? (I need to use a COM object as INPROC and this object is only available for 64 bit architecture)
I do not see any reason why not. You would need:
To be working on a 64-bit processor,
Ensure you have the Visual Studio 64 bit edition
Compile Qt on that 64 Bit setup
Compile QtCreator on that setup
The email says that debugging tools would also need to be compiled. I am not sure which debugger QtCreator uses but I would image it would be open source and you could compile it on that setup anyway.
Qt probably do not do it by default because they already produce loads of different builds for all the platforms they support and there has not yet been a large demand for 64bit windows desktop applications.
Pekka Gaiser correctly pointed to an email from Trolltech. Basically, that's it :)
Specifically: Seemingly there is no 64 bit cross-compiler for Windows (due to that, there is no 64bit VLC for Windows). Therefore, the Microsoft compiler must be used. Unfortunately, Creator's support for Microsoft's toolchain is limited (although they make big steps towards supporting it fully).
Again: The email pointed to by Pekka Gaiser contains the information and links for using Qt Creator with Microsoft's 64bit toolchain.

Resources