For instance, if i wanted to cross compile 32 and 64 bit applications via gcc, I can use the -m32 & -m64 flags during compilation and linking. This method is different for visual studio because I have to run vcvarsall.bat x86 to compile for 32 bit and vcvarsall.bat x64 for 64 bit to setup my environment for compilation.

The above sample would not work because you need to rerun the vcvarsall.bat environment script in between compilation of 32 and 64 bit. If I try to compile the above sample makefile when after running vcvarsall.bat x86, I would get this error when trying to link the 64 bit executable:

1 Answer
1

You don't have to use vcvars. Those are convenience scripts for building in one platform environment or the other. By explicitly invoking the proper commands and passing them the appropriate options you can compile both without having to invoke two different batch files.

Here is one way to write your "foo" program example as a GNU makefile:

Thanks, that was it! If you didn't run vcvar before compiling, you will need to set the INCLUDE environment to point to the Windows SDK include directory and the Visual Studio VC include directory as well.
– Mark TrinhApr 28 '11 at 14:58