hello.c:
#include
#include
int main(int argc, char *argv[])
{
printf("Hello world!\n");
return EXIT_SUCCESS;
}
hello.bat:
@ECHO OFF
SETLOCAL
CALL "%VS80COMNTOOLS%..\..\vc\vcvarsall.bat" x86
cl /MT /c hello.c
ENDLOCAL
SETLOCAL
CALL "%VS80COMNTOOLS%..\..\vc\vcvarsall.bat" amd64
link /MACHINE:x86 /LIBPATH:"%VCINSTALLDIR%\lib" libcmt.lib hello.obj
ENDLOCAL
output:
C:\Project>hello.bat
Setting environment for using Microsoft Visual Studio 2005 x86 tools.
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
hello.c
Setting environment for using Microsoft Visual Studio 2005 x64 tools.
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Project>hello.exe
Hello world!