-
Notifications
You must be signed in to change notification settings - Fork 463
Building libbladeRF for Windows
Be advised that building libbladeRF for Windows is a somewhat difficult process with a lot of manual steps, and this documentation may not be up-to-date with all of the necessary preparations.
Unless you specifically need to modify libbladeRF itself, it is strongly recommended to use our pre-built, signed installer. See Getting Started: Windows for information on getting and installing this. If you have already installed it, you can proceed to Getting Started: Verifying Basic Device Operation.
- Download and install Git for Windows from their Downloads page.
- Download Visual Studio Community 2017 for Windows Desktop from Microsoft, which can be found at https://www.visualstudio.com/downloads/
- Follow the installation instructions, including any post-install updates.
Tip: You can download time-limited virtual machine images from Microsoft with the latest Windows 10 and Visual Studio builds from https://developer.microsoft.com/en-us/windows/downloads/virtual-machines
- Download the latest Windows binary release of libusb, which also include development headers. As of this writing, version 1.0.22 is the latest.
- Note: download the libusb-1.0.xx.7z file from the GitHub release
- Note: you may need to download and install 7-zip from 7-zip.org to open this file.
- Extract the contents to a location of your choice. Make note of this location so that you can later provide it to CMake. The default configuration assumes that files will be in
C:/Program Files (x86)/libusb-1.0.22
, but if you wish to change the directory, you can change theLIBUSB_PATH
in CMake.
- Get the device driver installer (zadig): http://zadig.akeo.ie (older versions: http://sourceforge.net/projects/libwdi/files/zadig/)
- Open Zadig.
- If the bladeRF is not already listed in the dropdown box, go to Device->Create New Device, type a device name (i.e., "bladeRF") in the text box, and specify the VID/PID (2cf0/5246 for bladeRF x40/x115, 2cf0/5250 for bladeRF xA4/xA9, 04b4/00f3 for any bladeRF device in bootloader/recovery mode) in the USB ID fields.
- In the driver spinbox, select libusbK.
- Click "Install Driver"
- Open Device Manager. A new device called bladeRF should show up. If there is a yellow bang next to it in device manager:
- Right-click on the bladeRF entry and select "Update Driver Software...".
- Choose "Browse my computer for driver software"
- "Let me pick from a list of device drivers on my computer".
- Click "Have Disk..." and point it to the location that Zadig installed the driver to (C:\usb_driver).
- Select "bladeRF" and continue through the wizard.
- Right-click on the bladeRF entry and select "Update Driver Software...".
- Device Manager should now show bladeRF under libusbK USB Devices.
- Repeat the Create New Device steps for any other bladeRF VID/PID combinations you expect to encounter.
The pthreads library is required to build libbladeRF and its utilities. A few steps are required to install this pthreads implementation. See the pthreads-win32 website for more information.
WARNING: pthreads-win32 version 2.9.1 does not work with newer versions of Windows / Visual Studio. See the "pthreads-win32 patch and recompile" section just below for a workaround.
- Download the latest release. Currently this is version 2.9.1.
- Extract the contents of the release zip.
- Copy the contents of the
Pre-built.2
directory toC:\Program Files (x86)\pthreads-win32
If you are using a newer version of Windows / Visual Studio and/or are getting error C0211: 'timespec': 'struct' type redefinition
when trying to build bladeRF, you will need to rebuild pthreads-win32. The below process works with pthreads-win32 2.9.1.
- Get full source tree from the pthreads-win32 website, and unpack someplace convenient
- In Visual Studio, open
pthreads-w32-2-9-1-release\pthreads.2\pthread.dsw
(if prompted, a one-way upgrade is OK) - Right-click the solution, select "Retarget solution", hit OK.
- Change "Solution Configurations" dropdown to "Release" ("Debug" doesn't work, but that's OK)
- Edit pthread.h to add
#define HAVE_STRUCT_TIMESPEC
and#define PTW32_ARCHx64
near the top, just below the include guard - Build the solution
- Copy the contents of the
pthreads.2
directory toC:\Program Files (x86)\pthreads-win32
.
Download and install CMake for Windows: http://www.cmake.org/cmake/resources/software.html
- Right click on the Desktop and select "Git GUI Here"
- Select "Clone Existing Repository"
- Paste
https://github.com/Nuand/bladeRF.git
into the Source Location field. - Select your preferred directory to clone the repository to, in the Target Directory field. This must be a directory that does not yet exist.
- Click "Clone" and let it run. When it's done, close the Git Gui window. The bladeRF code is now on your computer.
- Run the CMake GUI utility.
- Under "Where is the source code", browse to
[preferred_directory]/bladeRF/host
. - Create a new directory,
[preferred_directory]/bladeRF/host/build
. - Under "Where to build the binaries", browse to the newly created
[preferred_directory]/bladeRF/host/build
. Click the Configure button. - Select your appropriate version of Visual Studio. For Visual Studio 2017, select "Visual Studio 15" or "Visual Studio 15 Win64". Select "Use default native compilers", then click "Finish".
- If the configuration fails, double check the values for
LIBUSB_PATH
andLIBPTHREADSWIN32_PATH
, and re-run the configuration. - Click on the Generate button.
- A Visual Studio solution should now be available,
host/build/bladeRF.sln
.
- CMake has created a
bladeRF.sln
file. Open Visual Studio, and open this file. (You can also click "Open Project" in CMake) - A number of projects should show up in the Solution Explorer, including:
- bladeRF-cli
- bladeRF-fsk
- libbladerf_shared
- Select Debug or Release build from the drop down menu at the top
- Run Build -> Build Solution
- After the build completes, you should see a
host/build/output
directory in the build directory, containing either a Debug or Release subdirectory. These directories will contain generated executables, libraries, and will contain copies of the required DLLs.
error C0211: 'timespec': 'struct' type redefinition
, see "pthreads-win32 patch and recompile" above. You may need to delete the [preferred_directory]/bladeRF/host/build
directory and restart from the "Configuring with CMake" step.
Open up a cmd.exe
window and navigate to the output directory associated with your build:
C:\Users\jon\Documents\projects\bladeRF\host\build\host\output\Debug>dir 10/19/2013 05:36 PM 122,880 bladeRF-cli.exe 10/19/2013 05:36 PM 139,776 bladeRF.dll ... Snipped out some other items ... 10/19/2013 05:35 PM 92,160 libusb-1.0.dll 10/19/2013 05:35 PM 55,808 pthreadVC2.dll
Note the presence of the libusb-1.0.dll
and pthreadVC2.dll
in this directory. These are placed here so that the bladeRF-cli and other tests may be run from this directory.
From here, you can continue on with the Getting Started: Verifying Basic Device Operation wiki page. If you encounter any errors or warnings, please see the Troubleshooting guide.