Building an executable from C++ or C# files


Building your project:

Create a compile.bat file that contains one of the statements below:
  1. build using IDE engine from command line:

    devenv mySolution.sln /rebuild debug // this is the easiest way
  2. build using VC++ compiler from command line:

    CL /DTEST_MYMODULE /EHsc MyModule.cpp, ... // list all cpp files
  3. build using C# compiler from command line:

    CSC /DTEST_MYMODULE MyModule.cs, ... // list all C# files
MySolution is the sln file generated by the IDE when you created a solution.
MyModel is the name of a module you want to build.
TEST_MYMODULE is the value of the string in #ifdef xxx preprocessor directive before the module's test stub main function.

You can see all of the options accepted by devenv using the command line command: devenv /?
The options available from the C++ compiler are show with the command line command: cl /?
The options available from the C# compiler are show with the command line command: csc /?

Note that this assumes that devenv.exe, CL.exe and CSC.exe are on your path. If you use the Visual Studio command shell then all the Visual Studio compilers, devenv, and other tools will be on your path. To test your batch files you will need to navigate to that directory or use their full path names.

To run the Visual Studio Command Prompt go to Windows start and select as shown here: Start->All Programs->Visual Studio 2012->Visual Studio Tools->Developer Command Prompt. When you open that you must navigate to the directory holding your compile.bat file and type compile.

Note that the TAs will grade on a machine with path including devenv so you simply use the batch file contents shown above.

Executing your project:

Create a run.bat file that runs your executuable, supplying it with all the command line options and file patterns it needs to demonstrate that you meet all project requirements.
  1. myExe.exe /n2 *.h *.cpp // these are example arguments. You supply what you need to run.

Submissions:

Before submitting, open VisualStudio and open your project. Clean the solution, then close VisualStudio. Then delete the *.sdf file and the ipch folder. Now, zip your project folder. Please use Windows Explorer to navigate to your folder, right-click and send to compressed file.
DO NOT USE RAR OR 7ZIP OR ....

To make sure your compile.bat and run.bat files work, create an empty directory, copy in your SomeStudentName-project1.zip file, extract it, and run your compile and run.bat files using the VisualStudio 2012 Command Prompt. You may find they don't work and can fix them before submitting so you won't lose points.

Late solutions lose 1 point per day. You are late if your upload is time-stamped after Midnight (even if only by one second).

Now submit using this script: upload script.