Compiling with VC++ from the command line


Up: Programming Tips Next: Compiling and linking with Fortran Previous: Compiling and linking with Microsoft Developer Studio (VC++ 6.x)

If you want to compile from the command line instead of using the MS Integrated Development Environment, here are the compile and link commands copied from the cpi project in the examples directory.

    1. Bring up a command prompt.
    2. Execute vcvars32.bat to set up the environment variables for VC++.
    3. compile example.c:

    Debug target: execute this:

    cl.exe /nologo /MTd /W3 /GX /Od /I "C: Program Files MPICH SDK include" /D WIN32 /D _DEBUG /D _CONSOLE /D _MBCS /GZ /c example.c

    Release target: execute this:

    cl.exe /nologo /MT /W3 /GX /O2 /I "C: Program Files MPICH SDK include" /D WIN32 /D NDEBUG /D _CONSOLE /D _MBCS /c example.c


    4. link example.obj:

    Debug target: execute this:

    link.exe ws2_32.lib mpichd.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
    comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib 
    odbc32.lib odbccp32.lib   
    /nologo /subsystem:console /debug /machine:I386 /out:"example.exe" 
    /pdbtype:sept   
    /libpath:"C:\Program Files\MPICH\SDK\lib"   
    example.obj 
    
    Release target: execute this:


    link.exe ws2_32.lib mpich.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
    comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib 
    odbc32.lib odbccp32.lib   
    /nologo /subsystem:console /machine:I386 /out:"example.exe"  
    /libpath:"C:\Program Files\MPICH\SDK\lib"  
    example.obj 
    
    Depending on what functions example.c uses, you may not need all the libraries specified above.



Up: Programming Tips Next: Compiling and linking with Fortran Previous: Compiling and linking with Microsoft Developer Studio (VC++ 6.x)