How can I install gcc 4.7.2 for codeblocks that supports both 32 and 64 compilation?

If I install the x32 bit compiler: x32-4.7.2-release-win32-sjlj-rev10 it will compile with -m32 compiler switch but give a bunch of linker errors for -m64

If I install the x64 bit compiler: x64-4.7.2-release-win32-sjlj-rev10 it will compile with -m64 compiler switch but give a bunch of linker errors for -m32

If I try both, it overwrites files of the other one.. If I install them both to a different directory, I have to change compiler toolchain-executables for each program I compile.

I got both from: http://sourceforge.net/projects/mingwbuilds/

So again, how can I get my gcc to be able to compile for both using the -m switch on windows? OR is there another way?

I have no problem using the 64 bit gcc to build for 32 bit targets. What error messages are you getting?

The actual problem is not the compiler, but the system libraries you need to link to. This is why you get all these linker errors. So, what is needed is an installation of GCC with the two sets of libraries, i.e., for 32bit and 64bit systems. Try the TDM-GCC releases, these are reliable releases and ahead of their game, and they do provide dual compilation releases (compiler + both sets of libraries).

Hmm but doesn't TDM only use gcc 4.7.1? I was told that doesn't have std::thread

The errors I was getting was:

undefined reference to ZSt4cout'| undefined reference toZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_x'|
undefined reference to `ZNSo5flushEv'|

I did indeed download the TDM as suggested. It works but for projects that use std::thread from 4.7.2, it will not compile those.

etc..

:O I solved it just now.. After creating a makefile, I was able to compile with -m32 and -m64.

So I figured there has to be a way to do this in Codeblocks.
I went did:

CompilerSettings->Other Options and added -m32

Then in Linker Settings under other linker options I added -m32

I only had the x64 compiler installed. It has lib32 folder included in it so that's why this works.

This question has already been answered. Start a new discussion instead.