Setting up Microsoft Visual C++ Solutions and Projects
The instructions below will describe the lab conventions for setting up solutions and projects in Visual C++. Please follow them closely.
- All projects should stem from the "Empty Project" template. This template has the best settings already in place (No precompiled headers, none of the additional windows bells and whistles). Every project name should be entirely lowercase, to match file name conventions.
- The default builds "Debug" and "Release" should be adapted for static libraries as applicable.
- Debug settings that need to be set (under Configuration Properties for the project):
- General
- Configuration Type: Static Library (.lib)
- Hit "Apply" after changing this to update the menus.
- C/C++ -> General
- Additional Include Directories: ../
- Preprocessor
- Preprocessor Definitions: _WINDOWS
- Release settings that should be changed (under Configuration
Properties for the project):
- General
- Configuration Type: Static Library (.lib)
- Hit "Apply" after changing this to update the menus.
- C/C++ -> General
- Additional Include Directories: ../
- Debug Information Format: Disabled (Shaves a bit off the output file; if bugs occur in release mode, change this to "Program Database (/Zi)"for debugging. Also, under Optimization, disable optimizations when debugging. Rebuild All whenever this setting is changed).
- Preprocessor
-Preprocessor Definitions: _WINDOWS;UTIL_FAST
- Set the project dependencies. Right click on the solution and select properties.
- Under Common Properties -> Startup Project, make sure "Single startup project" is selected and make it the current project.
- Under Common Properties -> Project Dependencies, go through every project and set up the "Depends on" relationships.
The test project needs to depend on every module with unit tests.
- If there is a test suite associated with this project. . .
- Right click the project and press Add->New Filter . . . Name it "Test Files".
- Place all test header files, "makerunner.pl", and "makerunnermodule.pl" in a folder named "test" in your project's physical directory. If there are any additional resource files used in the tests, place them in a directory called "files" in the "test" folder.
- Create a blank text file named "runner.cpp" in the directory.
- Include all header files and runner.cpp in the "Test Files" filter in MSVC++.
- Open the properties page for ONE of the header files. Set "All
Configurations" as the active Configuration.
- Select Custom Build Step >> Command Line, and click the ellipses ("...").
- Enter:
cd "$(InputDir)"
perl "makerunnermodule.pl"
- Also change Custom Build Step >> Outputs to "runner.cpp" (no quotes). Apply/ok these properties.
- Add the project "test" to your solution. Executing this project (in
either debug or release configuration) will run all unit tests.
- To run the test project executable, execute it within MSVC. To do this, right click on the "test" project, select "Set as StartUp Project" and then Debug -> Start Without Debugging.
- The library should now successfully compile.
- When committing the library, only the following files should be uploaded:
*.cpp
*.h
test/*
Makefile
*.sln
*.vcproj
All other files should be automatically generated at compile time.
- If you want to create an executable for your project, you will need to create a folder called "exec" in your project folder. Inside "exec", you will need a file with a main function.