Author Topic: Using -m32 Flag throws error in compilation  (Read 7789 times)

Offline 0xbrokenmind

  • Single posting newcomer
  • *
  • Posts: 2
Using -m32 Flag throws error in compilation
« on: December 08, 2021, 09:02:24 pm »
Hi,
I am using codeblocks-20.03mingw. With default setting, the program is compiled for 64-bit systems. I want to compile the program to 32-bit system. I enabled -m32 flag in Setting->Compiler->Global compiler settings->GNU GCC compiler->Compiler settings. When i build the program, it throws following error. Pls see the attached image. How to build my program only for 32-bit system. Not for 64-bit system

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7665
    • My Best Post
Re: Using -m32 Flag throws error in compilation
« Reply #1 on: December 08, 2021, 10:15:55 pm »
Step 1: Install an 32 bit MinGW Compiler
Step 2: Configure Code::Blocks IDE to use it.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline 0xbrokenmind

  • Single posting newcomer
  • *
  • Posts: 2
Re: Using -m32 Flag throws error in compilation
« Reply #2 on: December 09, 2021, 05:59:43 am »
Thanks.

I tried as you told. It works. Now I can compile a program for 32-bit system {using 32-bit mingw} & 64-bit system {using default codeblocks' mingw}.

Is there any work-around to compile for 32-bit system by using default codeblocks' mingw?

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 678
Re: Using -m32 Flag throws error in compilation
« Reply #3 on: December 09, 2021, 07:47:13 am »
Download the C::B package that has the 32bit Mingw compiler bundled with it, codeblocks-20.03mingw-32bit-setup.exe.... But then you will build 32 bit exes and you would need to install the 64 bit Mingw.

It may be easier to effectively start again and grab C::B without a compiler and then install both the 32 and 64 bit MinGW compilers separately. You then swap the compiler directory via the compiler settings to point to with the 32 or 64 bit compilers.