SpinCore Logo french.png   korean.png   russian.png   german.png   italian.png   port.png   espanol.png   japanese.png   Contact Us
Software Downloads

banner_left.jpg banner_right.jpg

Help For Compiling On Windows

   This document describes how to interface with the SpinAPI control library, which is used to control all SpinCore products, including PulseBlaster, PulseBlasterDDS, PulseBlasterESR, PulseBlasterESR-PRO, and RadioProcessor.

Windows Compilation

   The SpinAPI control library is a standard windows .dll which can be accessed from a wide variety of programming environments, such as C/C++ programs, LabView, etc.

Accessing SpinAPI From a C/C++ Program:

   This section describes the basic steps needed to get your C/C++ program to work with SpinAPI.  Virtually any C/C++ compiler/programming environment is compatible, feel free to use your favorite.  If you do not currently have a C/C++ compiler, there are several high quality compilers available for free download on the internet, see below for some recommendations.

 Four files are necessary to be able to control your board using this approach:

  1. .c/.cpp file: This is the program itself. Several example C programs are included for each of our different products.

  2. spinapi.h: The SpinAPI header file. This contains the function declarations and definitions which are needed to access the SpinAPI functions. This should be #included in all files which use the SpinAPI functions. (#include "spinapi.h")

  3. Import library: This library must be linked with your program so it will know to look inside the spinapi.dll file to find the API functions. There are several different file formats for import libraries, so we have provided three different ones so that all compilers can be supported. Choose whichever is appropriate for the compiler you are using.  These libraries can be located in the C:\SpinCore\SpinAPI\dll directory.
    • spinapi.lib: Microsoft compilers
    • libspinapi.a: GCC based compilers (such as MinGW)
    • For Borland compilers please contact SpinCore

  4. spinapi.dll: The control library itself. Windows must be able to find this file when you run your program, so it needs to be placed in the same directory as the executable program, or in one of the Windows directories (such as C:\Windows\System32)

The most straightforward way to compile a program using SpinAPI is to create a new, empty directory and copy each of the four required files listed above into it. Look in the dll/ directory to find spinapi.h, spinapi.dll, and the import library. An example C program can be found the the appropriate product subdirectory. Then open the C file, configure your compiler to link with the import library, and start the compile. It is recommended that you compile one of the unchanged example programs first, to ensure your compiler is set up correctly. Once the example is compiled correctly, you can move on to creating custom programs.

Below are detailed instructions for specific compilers on how to configure them to use SpinAPI. The procedure for other compilers should be similar. These instructions assume you have copied the four required files into their own directory as described above.

Microsoft Visual Studio 6:

  1. Open the C file.

  2. Select "Build | Compile zzz.c" from the menu. (zzz.c will be the name of the C file you opened)

  3. You will be asked if you wish to create a new workspace. Answer yes.

  4. You must tell the compiler to use the import library. Choose "Product | Settings..." from the menu. Click on the "Link" tab. In the "Object/Library modules:" box, add spinapi.lib in addition to the libraries already listed, and click "Ok"

  5. Everything is now configured correctly. To build the executable, simply choose "Build | Build zzz.exe" from the menu, and the program will be created and placed in the Debug subdirectory.


Dev-C++:

  1. Open the C file.

  2. Choose "Tools | Compiler Options".

  3. Under the "Compiler" tab, check the "Add these commands to the linker command line" box, and enter "-lspinapi" (that's a lower-case L) in the text box below. Use "-lspinapi64" instead for 64-bit systems.

  4. Under the "Directories" tab, choose the "Binaries" tab and add the directory where the libspinapi.a file is located. (Click the icon with a picture of a folder on it, choose the directory in the dialog box that pops up, and click the "Add" button). Under a default installation of SpinAPI, this directory would be "C:\SpinCore\SpinAPI\dll" for 32-bit systems and C:\SpinCore\SpinAPI64\dll for 64-bit systems.
  1. Repeat Step 4, but with the "Libraries" tab, which is also under "Directories"

  2. Repeat Step 4, but with the "C Includes" tab, which is also under "Directories"
  1. Under the "Programs" tab, in the "make:" row, click the icon with a picture of a folder on it. Choose the program "mingw32-make.exe" in the dialog box that pops up, and click the "Open" button. Under a default installation of Dev-C++, this directory would be "C:\Dev-cpp\bin"

  2. Everything is now configured. Choose "Execute | Compile" from the menu to compile the program.

Free C/C++ Compilers:

    Dev-C++: This is a free C/C++ programming environment. It is available from http://www.bloodshed.net/dev/devcpp.html. Be sure to choose the larger download which includes the GCC MinGW compiler. The graphical interface of this environment is very usable, but not quite up to standard with commercial offerings. However, the underlying compiler is of high quality (it is the Windows version of the gcc compiler used on linux) and is what we use for much of our internal software development.

NOTE: Please make sure that only one version of MinGW is installed at a time. If multiple versions are installed, Dev-C++ will be unable to compile.


Accessing SpinAPI From Other Programming Environments:

    Virtually all programming environments provide some mechanism for accessing an API provided by a Windows .dll. Please consult the help files of your environment if you are unsure of how to do this.


General Tips

  • We highly recommend you check the result of the pb_get_version() function at the beginning of each program. This way, if you upgrade to a newer version of SpinAPI, you can check to make sure your program is not accidentally still using the older version of the library.

  • Checking the return value of all SpinAPI functions is highly recommended. This way you will be able to detect common errors (such as entering too short a time for an instruction length, etc.)

  • If you encounter difficulties controlling your board with SpinAPI, you can enable debugging features by calling pb_set_debug(1) on the first line of your program. This will create file called log.txt when you run your program, which can then be emailed to us along with a description of the problem to help us solve your problem as quickly as possible.


Home | Products | Design Services | Applications | Contact Us | Purchasing Info | About Us | Software Downloads

© 2012 SpinCore Technologies, Inc.