Visual C++ 2010 - Creating a new Win32 Console Application:
This information is for Visual C++ 2010 (Express). Earlier versions of Visual C++ will be similar, but with slight differences in the locations of various menu options. Let us assume you have a directory "MyProject", containing the source code (.c, .cpp, or .h) files for your project.
- Launch Microsoft Visual C++
- Select "File → New → Project..."
- This will bring up a window "New Project".
- Select "Win32 Console Application".
- Under "Name", enter your project name (e.g., "MyProject").
- Under "Location", click "Browse" and navigate to the directory containing your source files.
- You can leave the box "Create a directory for solution" checked (it doesn't matter much).
- Click "OK".
- Next a window "Win32 Application Wizard" will come up.
- Click the "Application Settings" button on the left.
- Under "Application type" be sure that "Console application" is selected.
- Under "Additional options" select "Empty project".
- Click "Finish".
- At this point, if you open a Windows Explorer window, you will see a new directory "MyProject in the directory with your source files. This is where Visual Studio stores all its configuration files. If you mess anything up, you can always go back and remove this directory and start over again. This important files are:
- MyProject.sln (solution file).
- MyProject.vcproj and/or MyProject.vcxproj (records compiler options for the project).
- There are a number of other files, but these the most important, since they are the only ones we need to compile your program submission.
- Returning back to the Visual Studio main window, go to the "Solution Explorer" section (probably on the left) and click "MyProject".
- Select "Project → Add Existing Item..." (Alternatively, you can right-click "MyProject" in the Solution Explorer window and select "Add → Existing Item" from here.
- This will bring up a window "Add Existing Item". Navigate up to the with your source files and (using control-click) select all your .cpp and .h source files.
- Click "Add". (In the Solution Explorer section, you should now see your .h files listed under "Header Files" and your .c and .cpp files listed under "Source Files".)
- To view/edit a file, double-click on it.
- If you need to set additional configuration options (e.g., directories to search for include files or .lib files).
- Select "Project → Properties...".
- This will bring up a window with lots of sections for various options.
- For example, under "Configuration Properties":
- If you want to select directories to search for header files select "C/C++ → General" and add these in "Additional Include Directories". (If you installed glut.h in the proper directory, you should not need to change this.)
- If you want to select directories to search for library files select "Linker → General" and add these in "Additional Library Directories".
- When you run your program, you may need it to execute in a particular directory (e.g., where your input files are stored) or with particular command-line arguments. To do this, select "Debugging" modify the Command Arguments or Working Directory entries. Command-line arguments are passed in to your main program using argc and argv arguments in your main program.
- To compile:
- If you don't see the Build menu at the top (it comes between "Project" and "Debug"), select "Tools → Settings → Expert Settings..."
- Select "Build → Build Solution" (or hit F7).
- Note that the compiler allows for two common compiler configurations.
- "Debug" adds additional debugging information to the compiled code.
- "Release" performs additional code optimization.
- If the compiler complains that it cannot find GLUT include files ("glut.h") check that it is placed in the proper directory. (See the entry above about "Additional Include Directories".)
- If the linker complains of unresolved GLUT externals, such as "glutInit", check that "glut32.lib" is placed in the proper directory. (See the entry above about "Additional Library Directories".)
- To run (in debug mode):
- Select "Debug → Start Debugging" (or hit F5). If the loader complains about missing dll's, then check that you have placed glut32.dll in the proper directory.
- You can also run your program from a standard command-prompt window (e.g., by selecting "Windows Icon → All Programs → Accessories → Command Prompt", navigating to the Debug or Release directory, and typing in "MyProject.exe").
- If your program complains that it cannot find your input files, then see the entry above about "Working Directory".
- To clean compilation files:
- On some Visual C++ versions you can remove compilation files using "Build → Clean Solution". (This option does not seem to exist on Visual C++ 2010 Express.)
- Before submitting, I would suggest deleting all the large binary files, such as "MyProject.exe", "MyProject.ncb", "MyProject.ilk" and "MyProject.pdb". These are quite large and are not needed to recompile your program.
|