Author Topic: problems with 32-bit executables in TDM mingw64 installation  (Read 8903 times)

Offline bootstrap

  • Multiple posting newcomer
  • *
  • Posts: 64
I've got the latest versions of codeblocks on my linux and windoze7 computers, with the latest version of TDM-GCC mingw64 (tdm64-gcc-461) from this webpage: http://tdm-gcc.tdragon.net/download.  For most of my applications, I defined the following targets:

linux32_debug
linux32_release
linux64_debug
linux64_release
windoze32_debug
windoze32_release
windoze64_debug
windoze64_release

To keep everything separate, and avoid unwanted interactions, all targets create separate directories with those same names to store their object files and executable.  For example: linux32_debug for object files and linux32_debug/bin for the executable.

The 32-bit and 64-bit versions of my applications now build fine on linux.  The 64-bit versions of applications also usually build and execute okay on windoze7.  The 32-bit versions of applications also build on windoze7, but... I cannot debug them.

Here is what happens when I create a simplistic "hello world" application with one main() function and only 3 printf() statements (more than one printf() so I can try to perform debug steps like "run-to-cursor", "single-step", etc).  I build=>clean, then build=>build.  The build process completes, though it prints out a couple dozen almost identical messages like the following:

c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.6.1/../../../../x86_64-w64-mingw32/bin/ld.exe:
skipping incompatible \mingw64\x86_64-w64-mingw32\lib\libmsvcrt.a when searching for -lmsvcrt

The only difference between the messages is the "libmsvcrt.a" part, which cycles through all sorts of files.

However, at the end, the compilation process claims to have completed with zero errors and zero warnings.

When I try to run "to-cursor" to the second printf() line, the console window appears and it contains the output from the first printf() line.  However, everything else is "busted".  Here's what I mean:

#1:  The yellow right-arrow that indicates "stopped-at-this-line" does not exist.
#2:  The "cpu register" window does contain register values, but the values appear to be totally bogus.
#3:  The "disassembly" window is empty, and the labels say "function: ??" and "frame start: ??".
#4:  The "call stack" window says:
  - nr = 0
  - address = 0008DC18
  - function = ?? ()
  - file = <empty>
  - line = <empty>
#5: The "debugger tab" window says:
  - debugger name and version GNU GDB (gdb) 7.3.1
  - child process PID: 4668
  - in ?? () ()
  - failure finding "Stack level "
  - failure matching reg_output

Given that the ebp register == 0x00000000, it is not surprising the debugger is having problems figuring out where the stack is (probably because it is getting the register values from the wrong place... or something).  And when I look at the memory at the eip register address (0x0008DC18), I see mostly 0x00 bytes with scattered data-looking values (groups of 4 non-zero bytes all aligned on mod-4 addresses), not opcode values.  Oddly though, at the displayed rip register address (0x004F3EEF), I see what might be code in the memory window.  I'm not sure how to make the disassembler disassemble those addresses to see for sure whether that is code --- it could be.  However, when I try to display memory at ANY of the other addresses in the 64-bit register values, the memory window cannot display those memory areas, which makes me suspicious that any of the 64-bit registers mean anything at all, rip included.

Also, once a breakpoint is hit once, "nothing else works".  Sometimes I can kill the program by clicking the square red "x" mark button on the codeblocks "debugger" menu bar (with the run-to, single-step, step-in, step-out, buttons).  However, other times codeblocks goes "clueless" and I have to force codeblocks to close to recover.

This is probably "my fault", and probably somewhere in the mountains of documents is something that would have prevented me from making whatever mistake I'm making.  The symptoms are a bit strange.  Obviously the program is hitting the debugger at the "run-to" line in the source code, because only the printf() statements before that line are executed.  Yet the registers and everything else are completely screwed up.

If I had to guess, I'd say "somehow" codeblocks is successfully linking my code to incorrect libraries, maybe even 64-bit libraries.  But hey, that's only a guess.  But I do suspect I need some switch or something in the 32-bit targets to make these problems go away.  Or maybe I need to add a search path.

One thing I don't have wrong:  I have -m32 and -m64 switches to both compiler and linker in every target.  I have noticed it creates 64-bit executables when the -m32 switch is not given.

Ideas, anyone?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: problems with 32-bit executables in TDM mingw64 installation
« Reply #1 on: July 02, 2012, 08:11:54 am »
Ideas, anyone?
Hard to tell w/o any code snippet. Can you try to strip your project to a minimal example and post it here?
I do win32/64 bit build with this compiler under Windows 7 regularly, including debugging and it works just fine...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline bootstrap

  • Multiple posting newcomer
  • *
  • Posts: 64
Re: problems with 32-bit executables in TDM mingw64 installation
« Reply #2 on: July 02, 2012, 10:49:00 am »
Ideas, anyone?
Hard to tell w/o any code snippet. Can you try to strip your project to a minimal example and post it here?
I do win32/64 bit build with this compiler under Windows 7 regularly, including debugging and it works just fine...

The program is one main() function with 3 printf() statements (of literal strings) inside, followed by return(0).  Do you really need to see this trivial code?  Oh, I #include <stdio.h> and <stdlib.h> at the top.  That's ALL there is.
 
« Last Edit: July 02, 2012, 11:14:25 am by bootstrap »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: problems with 32-bit executables in TDM mingw64 installation
« Reply #3 on: July 02, 2012, 10:56:16 am »
The program is a simple main() functions with 3 printf() statements (of literal strings) and then return (0).  Do you really need to see this trivial code?  Oh, I #include <stdio.h> and <stdlib.h> at the top.
 
I am looking especially for the project file with your project configuration, compiler setup etc.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline bootstrap

  • Multiple posting newcomer
  • *
  • Posts: 64
Re: problems with 32-bit executables in TDM mingw64 installation
« Reply #4 on: July 02, 2012, 11:21:57 am »
I attach the project files, including the project and all the directories and such, complete with object files and executables.

If there is another file for codeblocks configuration itself, I don't know where that is kept.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: problems with 32-bit executables in TDM mingw64 installation
« Reply #5 on: July 02, 2012, 03:06:15 pm »
I attach the project files, including the project and all the directories and such, complete with object files and executables.
Al-right, with the project you've attached I cannot reproduce the error. I tried compiling all with TDM's 64 bit compiler - this works. Another trial with compiling the 32bit versions using the 32bit version of TDM and 64bit with 64bit version of TDM (which is my usual config) works, too. ???
Maybe you have screwed your compiler installation(by overwriting files during an update) or you have stuff in the PATH environment that does not belong there?

Try a full clean re-install of TDM's compiler.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline bootstrap

  • Multiple posting newcomer
  • *
  • Posts: 64
Re: problems with 32-bit executables in TDM mingw64 installation
« Reply #6 on: July 03, 2012, 03:58:22 am »
I attach the project files, including the project and all the directories and such, complete with object files and executables.
Al-right, with the project you've attached I cannot reproduce the error. I tried compiling all with TDM's 64 bit compiler - this works. Another trial with compiling the 32bit versions using the 32bit version of TDM and 64bit with 64bit version of TDM (which is my usual config) works, too. ???
Maybe you have screwed your compiler installation(by overwriting files during an update) or you have stuff in the PATH environment that does not belong there?

Try a full clean re-install of TDM's compiler.
I uninstalled TDM64, deleted the remaining [empty] mingw64 directory tree, then fresh installed TDM64 again.  I then started codeblocks and tried to debug the windoze32_debug target, but the behavior has not changed?

Is there any point in removing and re-installing codeblocks too?  My codeblocks installation was from file <codeblocks_20120617_rev8059_win32.7z>.

BTW, did you find the project settings to be okay?

I guess the next question will be, do I have the toolchain set incorrectly, or the search path, or something else?  Under settings => compiler => toolchain-tab, I select executables in the <c:/mingw64/bin> directory.  Is that correct?  Also, the path for all targets is <c:/mingw64/x86_64-w64-mingw32/include>.  I don't specify a search path for libraries.  Should I ???  What other setting might I have wrong?
« Last Edit: July 03, 2012, 04:01:18 am by bootstrap »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: problems with 32-bit executables in TDM mingw64 installation
« Reply #7 on: July 03, 2012, 07:48:58 am »
BTW, did you find the project settings to be okay?
Yes, otherwise I wouldn't have been able to compile your project.

I guess the next question will be, do I have the toolchain set incorrectly, or the search path, or something else?
As I said: I have both: The 32 bit and the 64 bit TDM compiler installed. Then the only change I made in the compiler options is that I setup the toolchain path and only for the 64bit compiler added under "other compiler options":
-fno-keep-inline-dllexport
-m64

...and under "other linker options" I added :
-m64

Under settings => compiler => toolchain-tab, I select executables in the <c:/mingw64/bin> directory.  Is that correct?
No. There is a message saying that you have to set the root folder (!), so, c:/mingw64. C::B will look into the bin folder automatically. The reason is that C::B can only "compute" the default include and lib path, if the root path is known.

Also, the path for all targets is <c:/mingw64/x86_64-w64-mingw32/include>.
That's wrong, too. You should not  need to setup any include folder there, especially not this one.

I don't specify a search path for libraries.  Should I ???
No. All it needs is the compiler's root folder. Don't fiddle with other settings if you are unsure.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline bootstrap

  • Multiple posting newcomer
  • *
  • Posts: 64
Re: problems with 32-bit executables in TDM mingw64 installation
« Reply #8 on: July 04, 2012, 11:06:15 am »
BTW, did you find the project settings to be okay?
Yes, otherwise I wouldn't have been able to compile your project.

Quote
I guess the next question will be, do I have the toolchain set incorrectly, or the search path, or something else?
As I said: I have both: The 32 bit and the 64 bit TDM compiler installed. Then the only change I made in the compiler options is that I setup the toolchain path and only for the 64bit compiler added under "other compiler options":
-fno-keep-inline-dllexport
-m64

...and under "other linker options" I added :
-m64
Let me make sure I understand.  I only have the 64-bit TDM package installed (the one I mentioned in my original message), which says it can build both 32-bit and 64-bit targets.  But you have separate 32-bit and 64-bit TDM packages installed, presumably because you try to support us morons out here in the wilderness, and therefore want to be able to test the same configurations we have.

Quote
Under settings => compiler => toolchain-tab, I select executables in the <c:/mingw64/bin> directory.  Is that correct?
No. There is a message saying that you have to set the root folder (!), so, c:/mingw64. C::B will look into the bin folder automatically. The reason is that C::B can only "compute" the default include and lib path, if the root path is known.
I see.  However, as part of my attempt to get everything working, I went down to each tool, one by one, clicked the "..." button, and browsed to the tool in the c:/mingw64/bin directory.  So no matter what I had set as the default search path for the tools, I assume this made sure the correct tools were being executed.  Or could this approach perhaps have caused me some troubles?

Quote
Also, the path for all targets is <c:/mingw64/x86_64-w64-mingw32/include>.
That's wrong, too.  You should not need to setup any include folder there, especially not this one.
Okay, I'll fix that.

Quote
I don't specify a search path for libraries.  Should I ???
No. All it needs is the compiler's root folder. Don't fiddle with other settings if you are unsure.
Wow, I got one thing right.

I'll try again as soon as I get my windoze7 system running again.  Unfortunately, as has become extremely common lately, I seem to be victim of macroshaft nastiness --- or possibly something else very strange.  I noticed the 4-core phenom2 CPU in my windoze system wasn't capable of AVX, which I need (wrote lots of AVX assembly on my linux system, which is much faster than the old SSE4+ code).  So I bought a new motherboard and 8-core FX8150 CPU to make my windoze computer identical to my linux computer.  Unlike the older versions of windoze I've had, windoze7 would not boot up the slightly different hardware (newer gigabyte motherboard, newer phenom2 CPU, but otherwise pretty much the same).  It offered to check for new hardware and boot up.  Didn't work.  Then I tried booting off the windoze7 install DVD to do the same.  Didn't work.  Booting off the DVD and trying to "repair" didn't work.  Linux live DVDs boot and run fine on the system, so presumably the new motherboard and CPU are okay.  It won't perform a fresh install either, probably because the original install was over my winxp64 drive, which now doesn't exist (to prove I was in fact performing an upgrade).  I guess having a windoze7 installation isn't sufficient to upgrade?  Freaking hell!  I guess I'll have to create a bogus winxp64 installation just so I can re-install windoze7.  Sigh, endless time-destroying hassles.  Once I get past this windoze7 hassle, and have windoze7 up and running again, I'll get back to getting this work.  Until then, a bit of a pause in the process.  At least I can continue working on linux!
« Last Edit: July 04, 2012, 11:09:07 am by bootstrap »

zabzonk

  • Guest
Re: problems with 32-bit executables in TDM mingw64 installation
« Reply #9 on: July 04, 2012, 01:40:01 pm »
Calling Windows "windoze" isn't funny, clever or original.