News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

32 and 64 builds with mingw on Windows (NEWBIE question)

Started by nji, May 03, 2020, 02:02:23 PM

Previous topic - Next topic

nji

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
...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.

BlueHazzard

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...

nji

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?

sodev

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.

nji

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)).

BlueHazzard

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 ....


nji

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!