Installing UHD and Boost in Windows

From EEL6528 Wiki
Jump to: navigation, search

Guide for installing UHD and Boost in Windows 7 (x64). I'm using the latest versions available and so far it works flawlessly (unlike my Wiki skills...).

Installing UHD, Boost, and VS2013 on Windows 7 x64

  • This guide is intended to help users with installing and using UHD on a Windows platform. Over time, these links may expire. It is up to the installer (you most likely) to make rational decisions on which installations to use past that.
  • Prerequisites:
    1. Windows 7, 64-bit (I haven't tested this on x86)
    2. Approximately 7GB of free disk space
    3. Approximately 1-2 hours for downloading and installing
  • All UF ECE students have access to MSDNAA. This is a wonderful resource that is freely available to us which provides development software, operating systems, etc. We will use this source to install Visual Studio 2013. Browse around when you're through, there's lots of cool stuff here.

Install VC++ Redistributable Packages for Visual Studio 2013

  1. Navigate to:
    http://www.microsoft.com/en-us/download/details.aspx?id=40784
  2. Click "Download"
  3. Select "vcredist_x86.exe
  4. Click "Next", your download should start
  5. Install by running the executable

Install UHD - Latest Release, VS2013, Win32

  1. Grab the latest release for VS2013 here:
    http://files.ettus.com/binaries/uhd_stable/releases/uhd_003.007.002-release/uhd_003.007.002-release_Win32_VS2013.exe
  2. Click the executable to start installation
  3. Agree to the terms (if you dare...)
  4. Ensure you select "Do not add UHD to the system PATH" as there is a bug in the installer.
  5. Proceed with the installation.

Add UHD to the system path environmental variable

  1. Click Start
  2. Right-click on "Computer"
  3. Click "Properties"
  4. On the left-hand pane, click "Advanced System Settings"
  5. Click "Environment Variables"
  6. Under "System Variables", scroll down to "PATH"
  7. Click "Edit", then append ";C:\Program Files (x86)\UHD\bin" to the end. Change this to wherever you installed UHD from step 2.5 above
    (it's usually
    C:\Program Files (x86)\UHD)
    and then add the "bin" directory. Ensure the semi-colon is present before the directory so your system path stays intact.
  8. Click OK to everything, logout and login for the changes to take effect.

Test your UHD Installation

  1. Open a command prompt by: Click Start, type "cmd", then press [ENTER]
  2. Type, "uhd_find_devices" and press [ENTER]
  3. At this point, you should see something similar to:
    Greene success uhd find devices.jpg

Install the Boost C++ API

  1. Go grab Boost 1.56 32-bit here: http://sourceforge.net/projects/boost/files/boost-binaries/1.56.0/boost_1_56_0-msvc-12.0-32.exe/download
  2. Install with all the defaults, this should place it in "C:\local\boost_1_56_0\"

Install VS2013 Ultimate

  1. Go to: http://www.eng.ufl.edu/msdnaa/
  2. Click: "Login In: Microsoft DreamSpark"
  3. Sign in with your
    UFL email account, or register if you're new
  4. Search: "Microsoft Visual Studio Ultimate 2013"
  5. Add to cart, checkout, and install
  6. Once you've downloaded the installer, either burn it to a disk or mount it with Daemon Tools, Magic ISO, etc...
  7. Install VS2013 with all the default options (we really just need the C++ compiler)
  8. Once installed and opened, ensure you register VS2013 with the key you received from MSDNAA/DreamSpark at checkout.

Creating a VS2013 Project Template for UHD

  • Using a project template for UHD applications isn't required, but it will save you time when starting applications and debugging simple mistakes. We're going to create a simple template in VS2013 that contains our UHD library includes, the Boost library includes, and a simple main source code.

Start a New Project & Populate It

  1. Launch VS2013
  2. Click "File", "New", "Project..."
  3. Choose an empty C++ project and give it a name. I used EEL6528_UHD_Template shown here
    Greene VS2013Template 1.png
  4. Once created, right-click on the project and open its properties
    Greene VS2013Template 2.png
  5. First thing, change to the "Release" environment. The UHD API was built in release mode and won't work off-the-bat in debug mode. You can change settings quickly from here
    Greene VS2013Template 3.png
  6. Next, add the "Include" directories for both Boost and UHD under "C/C++", "Additional Include Directories". These directories are commonly,
    • UHD: C:\Program Files (x86)\include
    • Boost: C:\local\boost_1_56_0
      Greene VS2013Template 4.png
  7. Next, add the library directories under "Linker", "Additional Library Directories". These directories are commonly,
    • UHD: C:\Program Files (x86)\lib
    • Boost: C:\local\boost_1_56_0\lib32-msvc-12.0
      Greene VS2013Template 5.png
  8. With the library directories added, we now specify that UHD is a dependency. This is added under "Linker", "Additional Dependencies". Just append "uhd.lib;" to the beginning, and don't forget to add the semi-colon.
    Greene VS2013Template 6.png
  9. Exit out of configuration by clicking "Apply". With your settings in place, let's add a simple main file to make it easier to get our projects up and going. You can do this by right-clicking on the "Source Files" folder under your project.
    Greene VS2013Template 7.png
  10. We want to add a main source file, so let's choose the C++ File template, name it "Main.cpp" and click "Add"
    Greene VS2013Template 8.png
  11. Here's an example of a sample script. This script is modified from the "uhd_find_devices" code with extra includes for future projects.
/*
*	Project:	<INSERT_PROJECT_TITLE>
*				EEL6528 - Digital Communications with Software-defined Radios
*
*	Author:		David J. Greene
*				University of Florida
*
*	Date:		<INSERT_DATE>
*
*/
 
 
// General Includes
#include <cmath>
#include <complex>
#include <csignal>
#include <fstream>
#include <iostream>
 
// UHD Includes
#include <uhd/exception.hpp>
#include <uhd/types/tune_request.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/utils/static.hpp>
#include <uhd/utils/thread_priority.hpp>
 
// Boost Incudes
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/math/special_functions/round.hpp>
#include <boost/program_options.hpp>
#include <boost/thread/thread.hpp>
 
 
int main(void) {
 
// Look for connected USRPs
uhd::device_addr_t hint;
uhd::device_addrs_t device_addrs = uhd::device::find(hint);
 
// Exit if none were found
if (device_addrs.size() == 0)
	std::cerr << "No UHD Devices Found" << std::endl;
 
// Display the USRPs Found
else for (size_t i = 0; i < device_addrs.size(); i++) {
	std::cout << "--------------------------------------------------" << std::endl;
	std::cout << "-- UHD Device " << i << std::endl;
	std::cout << "--------------------------------------------------" << std::endl;
	std::cout << device_addrs[i].to_pp_string() << std::endl << std::endl;
}
 
// Pause for the user
system("pause");
 
// Exit the program
return 0;
}
  • Now, test the code by running it. You should see something like the image below (assuming you have a device attached)
    Greene VS2013Template 9.png


Exporting the Project Template

  1. With the template project open, click "File" then "Export Template..."
    Greene VS2013Template 10.png
  2. You can keep the default settings in place. Visual Studio is telling you that it will create a "Project Template" (which is what we want) and it selects the project currently open (EEL6528_UHD_Template) as the new template.
    Greene VS2013Template 11.png
  3. Now, give it a name, description, and feel free to add a picture of your project type so it's easy to find. Visual Studio will export the project into the VS2013 folder of your Documents. Furthermore, if checked below, it will automatically add it to the list of project templates that you choose when you start a new project.
    Greene VS2013Template 12.png
  4. Great Job! Now when you click "New Project" in Visual Studio, you're new project template should be visible. Here, I've listed it as "UHD Project" with a picture of the N210 from Ettus. When I start a new project with this template it will automatically set all my include, library, and dependency directories for me. Furthermore, my template "main" source code will be there so I can get straight to work!
    Greene VS2013Template 13.png