Author Topic: 32 and 64 builds with mingw on Windows (NEWBIE question)  (Read 6716 times)

Offline nji

  • Multiple posting newcomer
  • *
  • Posts: 54
32 and 64 builds with mingw on Windows (NEWBIE question)
« on: May 03, 2020, 02:02:23 pm »
I recently installed 64bit build of v.20.03, bundled with mingw (on Window7 64bit).

Building a simple console app it builds it to 64bit without problems.

When I have a look at the project's build options
Compiler Settings/ Compiler Flags / General
there are Targets 32 and 64 bit, both deselected.

But in the command line there is -m64. Why?

If I choose 32bit target in the compiler settings (-m32)
both -m32 and -m64 are used for the command line.
What is the effect by that?

Also the linker gives lots of errors then like
Code
...ld.exe: cannot find -lstdc++

What do I have to do additionally to build 32bit apps?

Simple questions, but maybe may be answered in short
and of help not only for me but for other new users.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: 32 and 64 builds with mingw on Windows (NEWBIE question)
« Reply #1 on: May 03, 2020, 03:13:15 pm »
If you have compiling problems, post a full rebuild log as described here:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

There are essentially 3 places where compiler options are set:
1) Global compiler settings: Settings->Compiler -> Select your compiler from the drop down at the top->Compiler settings
2) Project level: Project->Build options->Select the project name on the left->Compiler
3) Target level: Project->Build options->Select the target name on the left->Compiler

All this options stack together...

Offline nji

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: 32 and 64 builds with mingw on Windows (NEWBIE question)
« Reply #2 on: May 03, 2020, 05:04:25 pm »
Better I'll try again:

I do the most sophisticated task of building a console app.
(All settings are as of installed C:B/ mingw).

Let it build ...

"Hello world!"

Then change the project's/ target's build options to -m32.
Do a rebuild ... and get the linker errors above.
What is missing?

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: 32 and 64 builds with mingw on Windows (NEWBIE question)
« Reply #3 on: May 03, 2020, 06:53:38 pm »
Mingw-w64 toolchains are not multilib, they can compile only for one architecture. To build for 32 bit you have to download a 32 bit toolchain and either update the GCC compiler configuration of CodeBlocks to use that one instead, or, if you want to build for both architectures, add a new compiler configuration and use that one in the project.

Offline nji

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: 32 and 64 builds with mingw on Windows (NEWBIE question)
« Reply #4 on: May 03, 2020, 07:02:03 pm »
Thank you.

So I misunderstood the 2nd note of
http://www.codeblocks.org/downloads/26
I thought 32/64 bit would mean the target.

(Still I wonder why the compiler allows to produce 32bit code, just the linker fails (see posts above)).
« Last Edit: May 03, 2020, 08:19:49 pm by nji »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: 32 and 64 builds with mingw on Windows (NEWBIE question)
« Reply #5 on: May 03, 2020, 08:31:46 pm »
Again... post a build log...
Again, i posted the location where the linker or compiler options are (replace compiler with linker in my uper direction) and look if there is a stray -m64 ....

Offline huycan

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: 32 and 64 builds with mingw on Windows (NEWBIE question)
« Reply #6 on: May 03, 2020, 08:45:18 pm »
If you want multilib... you can download from here: https://sourceforge.net/projects/mingw-w64/files/Multilib%20Toolchains%28Targetting%20Win32%20and%20Win64%29/ray_linn/gcc-9.x-with-ada/ then you can use the switch -m32 and -m64

Offline nji

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: 32 and 64 builds with mingw on Windows (NEWBIE question)
« Reply #7 on: May 03, 2020, 09:19:42 pm »
Well, my tiny newbie question does seem not to be as "newbie" as I thought :-)

As I already wrote in my former post the bundled mingw does only 64bit.

(@BlueHazzard: Please notice that there is no sense in posting a log etc.)

If the multilib bundle works, it should be a fine thing...
and this thread of a help not only for me.

Thank you all of you!