Author Topic: Compiling 32 bit on 64 bit Windows 7  (Read 9028 times)

Offline dnabled

  • Single posting newcomer
  • *
  • Posts: 2
Compiling 32 bit on 64 bit Windows 7
« on: May 19, 2011, 05:20:45 am »
Hello
I'm using TDM-GCC compiler, and trying to compile a simple hello world for 32 bit using -m32 in other options under compiler and debugger and I get this error.

C:\Users\Dnabled\Documents\C++ Work\Test.o:Test.cpp|| undefined reference to `___main'|
C:\Users\Dnabled\Documents\C++ Work\Test.o:Test.cpp|| undefined reference to `__ZSt4cout'|
C:\Users\Dnabled\Documents\C++ Work\Test.o:Test.cpp|| undefined reference to `__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc'|
C:\Users\Dnabled\Documents\C++ Work\Test.o:Test.cpp|| undefined reference to `__ZNSt8ios_base4InitD1Ev'|
C:\Users\Dnabled\Documents\C++ Work\Test.o:Test.cpp|| undefined reference to `__ZNSt8ios_base4InitC1Ev'|
C:\Users\Dnabled\Documents\C++ Work\Test.o:Test.cpp|| undefined reference to `_atexit'|
c:\program files\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\4.5.2\..\..\..\..\x86_64-w64-mingw32\lib\libmingw32.a(lib64_libmingw32_a-crt0_c.o)||In function `main':|
c:\crossdev\src\mingw-w64-svn\mingw-w64-crt\crt\crt0_c.c|18|undefined reference to `WinMain'|
||=== Build finished: 7 errors, 0 warnings ===|

Using -m64 works well.
the code:
#include<iostream>
using namespace std;

int main()
{
 cout << "This is for you.";
}

According to TDM-GCC I should be able to compile for both 32 and 64 bit using their 64 bit compiler and the -m32 command. Am I doing something wrong? I need to make 32 bit programs because at school the OS  is 32 bit and we get projects from time to time.

Thank You

Offline dnabled

  • Single posting newcomer
  • *
  • Posts: 2
Re: Compiling 32 bit on 64 bit Windows 7
« Reply #1 on: May 19, 2011, 12:37:14 pm »
Found a work around.

Installed TDM-GCC for 32 bit only in a different location and pointed the toolchain executable to that folder. The code compiles without errors and works on windows xp 32 bit.
It seems the normal MingW compiler for 32 bit always requires a certain lib gcc dw2 dll to be in the same folder as the executable in order for it to run(outside the IDE). However, TDM's version doesn't require that file meaning better portability.