Compilation with Microsoft Visual C++
This document is designed to walk one through the
process of configuring Microsoft Visual C++ to compile
C code based on the SpinCore PulseBlasterDDS-IV API.
It details the process of adding the proper include
and library paths, as well as the required library
dependency. Microsoft Visual C++ 2010 SP1 Express was
used for generating the instructions and images. The
directions should apply to older or newer versions of
Visual C++, with minor differences.
2 Create Project
- Open Microsoft Visual C++
- Select “File > New >
- Select “Win32 Console
- Specify your project name and
1: New Project Wizard
Please click “Next” on this page.
2: Win32 Application Wizard Page 1
- Click the “Console
application” radio button.
- Select “Empty project” under
additional options. An empty project will be used
for this guide since the source code is already
written, and will be copied to the project
directory. You may opt to not create a blank project
if you wish to write new code based on the initial
files Visual C++ will generate.
- Click finish.
3: Win32 Application Wizard Page 2
3 Configure Project
3.1 Adding Source Files
- Copy your source file into
the project directory, and select “Project > Add
- Select your source file
located in the project directory, and click “Add.”
For this example, the
“pbddsiv_read_firmware_example.c” example program
was used. The figure below shows what your “Solution
Explorer” pane should display after adding the file.
4: Visual C++ Main Window, after source
file is added.
3.2 Adding Include Paths
First we will configure Visual C++ so that it will
- Go to “Project >
- In the upper left corner of
the “Property Pages.” window, please select “All
Configurations” in the “Configuration:” drop-down
- In the left pane select
“Configuration Properties > C/C++ > General.”
- In the main view, add the
path where “ddsivapi.h” is located
to the “Additional Include Directories” property. In
this case it is located in
- Click “Apply.”
5: Visual C++ Property Pages
3.3 Adding Library Paths
Next we will add the library search path for
“pbddsiv.lib”. The Property Pages should still be open
from the previous step.
- Please navigate to
“Configuration Properties > Linker > General”
in the left panel.
- Now add the path to the
library to the “Additional Library Directories”
property. In this case, the path was
- Click “Apply.”
6: Visual C++ Property Pages
3.4 Adding Library Dependency
Now the dependency on “pbddsiv.lib” needs to be
added. The Property Pages should still be open.
- Navigate to “Configuration
Properties > Linker > Input” in the left
- For the “Additional
Dependencies” attribute, please click once on the
field, then select the drop-down arrow and click
“<Edit>”, which should bring up the menu shown
in the figure below.
- Enter the name of the
library, which in this case is “pbddsiv.lib”.
- Press “OK.”
- Press “OK” on the Property
7: Visual C++ Additional Library
Now that the project has been properly configured, to
compile the project please go to “Build > Build
Solution” or press F7. If you do not want debug data
to be compiled into your executable, please select
“Release” rather than “Debug” in the “Solution
Configurations” drop-down menu on the toolbar.
8: Visual C++ Compilation Complete
4.1 Common Compilation Issues
- The Visual C++ C compiler
requires that all variable declarations occur at the
beginning of a block. If this convention is not
obeyed, Visual C++ will usually give errors about
- Sometimes code that will
compile in another compiler (such as GCC) will
require additional includes for functions that are
implicitly defined (e.g.: “system()” requires
“stdlib.h”). This will give a warning at compile