raytraced image (origin unknown)

Warning: This file is copied from last semester. If you spot errors or broken links, please let me know so I can update it.

Visual C++ 2010 - Creating a new Win32 Console Application:

This information is for Visual Studio (C++) 2010 (Express) and (as indicated in italics, Visual Studio 2012) Earlier versions of Visual C++ will be similar, but with slight differences in the locations of various menu options.

  • 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". (For VS 2012, uncheck "Security Development Lifecycle (SDL) checks".)
    • Click "Finish".
  • At this point, if you open a Windows Explorer window, you will see a new directory "MyProject in the directory into which you can copy 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. The two most important files are:
    • MyProject.sln, which is the solution file.
    • MyProject.vcxproj (or MyProject.vcproj on earlier versions), which stores various compiler options for the project.
    • There are a number of other files, but they are not essential in the sense that they will be regenerated if deleted.
  • 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..." (For VS 2012, this will be "Project → MyProject 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, otherwise add the directory containing it..)
      • In some versions of Visual Studio you need to indicate which library files to include. Under Linker → Input select "Additional Dependencies" and add "opengl32.lib", "glu32.lib", and "glut32.lib".
      • If you want to select directories to search for library (.lib) 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.
  • When finished, click OK.
  • 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).
      • If the compiler complains that it cannot find "GLUT/glut.h", check that you installed glut.h in the proper directory and double-check the "Additional Include Directories" property above.
      • If the compiler complains that it cannot find "GLUT/glut.h", check that you installed glut.h in the proper directory and double-check the "Additional Include Directories" property above.
    • 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.

-   CMSC 427 Home   -