Build Windows

Vincent Sonnier edited this page Oct 14, 2018 · 38 revisions

Windows7/Windows 8.1/10, Visual Studio 64-bit: -- improvements welcome.

Overview

This guide describes how to build CubicSDR together with its dependencies and some common SoapySDR modules (support for SDR hardware). While the focus is on Visual Studio 2017, it works also for Visual Studio 2015. The 2017 version is just a better 2015 version in every way, so use this one preferably. Visual Studio 2017 also has a better optimizing compiler which may result a faster CubicSDR.

Interesting point, VS2017 produces binaries compatible with VS2015 ones so there is no point of not using VS2017 whatsoever.

Alternatively if you don't want to compile anything and use pre-built binaries instead, you can install the PothosSDR distribution (Resources / Download installer) which contains a Win64 build of the latest CubicSDR source code together with all the existing SoapySDR modules to talk to any SDR device. Given a new version is released roughly every month, you may get more recent CubicSDR binaries than from the official release page.

Install Visual Studio Community 2017

If you don't already have Visual Studio 2017 you can install the free Microsoft "Visual Studio Community 2017" version available from https://www.visualstudio.com/downloads/ which was used for this guide.

During installation with the 'Visual Studio Installer' make sure you select at least the C++ Desktop development category or you'll be unable to compile the project due to the missing C++ tools. Alternatively, you can select more focused Individual Components for a finer-grained installation.

Build wxWidgets

Download https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.zip and unzip it to somewhere such as C:\MSVCDev\wxWidgets-3.1.1

Navigate to C:\MSVCDev\wxWidgets-3.1.1\build\msw (or wherever you extracted) and open wx_vc15.sln.

Choose Release and x64 for the build configuration and "Build Solution". All should compile successfully and you can close the project. This configuration effectively builds wxWidgets as a static library, later linked with CubicSDR.

Install CMake

Download CMake from:

For this guide I've used:

As recommended, uninstall the older CMake version first if present, then just install CMake with default or preferred options.

Install SoapySDR

Download ZIP or clone SoapySDR from https://github.com/pothosware/SoapySDR to C:\MSVCDev\SoapySDR

  • Launch CMake, set source path to C:/MSVCDev/SoapySDR/
  • Set destination to C:/MSVCDev/SoapySDR_win64/
  • Click "Configure" and choose "Visual Studio 15 2017 Win64" and Finish
  • Set CMAKE_INSTALL_PREFIX to C:/MSVCDev/SoapySDR_win64_install
  • Set SOAPY_SDR_ROOT to C:/MSVCDev/SoapySDR_win64_install
  • Click Configure again, all should be good, then Generate.

Open "Developer Command Prompt for VS2017" by right-clicking and "Run as Administrator".

From the prompt:

C:\> cd C:\MSVCDev\
C:\MSVCDEV> cmake --build SoapySDR_win64 --config Release --target clean
... Bunch of messages ...
    0 Error(s)
C:\MSVCDEV> cmake --build SoapySDR_win64 --config Release --target install
... Bunch of building ...
    0 Error(s)

Build CubicSDR

  • Clone or download ZIP from https://github.com/cjcliffe/CubicSDR/ to C:\MSVCDev\CubicSDR
  • Run CMake GUI
  • Choose C:\MSVCDev\CubicSDR for source.
  • Choose C:\MSVCDev\CubicSDR_win64 for build folder.
  • Click Configure.
  • Choose "Visual Studio 15 2017 Win64" and Finish.
  • Set wxWidgets_ROOT_DIR to C:\MSVCDev\wxWidgets-3.1.1
  • Set wxWidgets_LIB_DIR to C:\MSVCDev\wxWidgets-3.1.1\lib\vc_x64_lib
  • Set CMAKE_INSTALL_PREFIX to C:/MSVCDev/SoapySDR_win64_install
  • Click "Configure" again

Configure variables to indicate CubicSDR that modules files will be searched in the [CubicSDR executable]\modules directory:

  • Set BUILD_INSTALLER to 1 (checked)
  • Click "Configure" again
  • Set BUNDLE_SOAPY_MODS to 1 (checked)
  • Click "Configure" again
  • Set BUNDLED_MODS_ONLY to 1 (checked)
  • Click "Configure" again
  • Set USE_HAMLIB to 1 (checked)
  • Click "Configure" again
  • Set HAMLIB_DLLS to C:/MSVCDev/CubicSDR/external/hamlib/64/libhamlib-2.dll
  • Set HAMLIB_INCLUDE_DIR to C:/MSVCDev/CubicSDR/external/hamlib
  • Set HAMLIB_LIBRARY to C:/MSVCDev/CubicSDR/external/hamlib/64/libhamlib-2.lib
  • Click Configure again, all should be good, then Generate.
  • Navigate to C:\MSVCDev\CubicSDR_win64 in Explorer and open CubicSDR.sln.
  • Once open select "Release" and "x64" build configuration and then "Build Solution" (F6)
  • CubicSDR.exe should now be in the output folder (i.e. C:\MSVCDev\CubicSDR_win64\x64).

Using existing Modules

The simplest way to make CubicSDR ready tu run at that point is to 'reuse' the modules and libraries from an existing Installer:

  • Download the CubicSDR win64 installer from official release page.
  • Run the installer and set C:\MSVCDev\CubicSDR_win64\x64 as the installation directory.

Then re-compile CubicSDR as described in the previous section:

  • Navigate to C:\MSVCDev\CubicSDR_win64 in Explorer and open CubicSDR.sln.
  • Once open select "Release" and "x64" build configuration and then "Build Solution" (F6)
  • CubicSDR.exe should now be re-generated in the C:\MSVCDev\CubicSDR_win64\x64 folder and ready to run.

Alternatively, see the following section to build the modules from scratch:

Building Modules and dependencies

SoapySDR modules need hardware-specific libraries to communicate with the hardware. Such libraries either come from Open Source Software or are provided by the hardware vendor. For instance,

  • SoapyRTLSDR needs:

    • pthreads-win32 : POSIX threads emulation for Windows,
    • libusb : low-level USB 'driver',
    • librtlsdr which use the 2 libraries above to communicate with the RTL-SDR device.
  • SoapySDRPlay needs:

    • mir_sdr_api : SDRPlay provides binaries for most common platforms (see SoapySDRPlay section below)

pthreads-win32

C:\MSVCDev\pthreads-win32\lib\x64\pthreadVC2.lib
C:\MSVCDev\pthreads-win32\include\*.h
C:\MSVCDev\pthreads-win32\dll\x64\pthreadVC2.dll

Copy the file pthreadVC2.dll in the C:\MSVCDev\CubicSDR_win64\x64 directory where CubicSDR can find it.

libusb

Use pre-compiled binaries ZIP from the libusb Releases page:

  • Unpack it as the following:
C:\MSVCDev\libusb-release\MS64\dll\libusb-1.0.dll
C:\MSVCDev\libusb-release\MS64\dll\libusb-1.0.lib
C:\MSVCDev\libusb-release\libusb-1.0\include\*.h

Or compile it from source:

  • Clone or download https://github.com/libusb/libusb to C:\MSVCDev\libusb
  • Build it using C:\MSVCDev\libusb\msvc\libusb_2017.sln choosing the Release and x64 configuration.

Copy the file libusb-1.0.dll in the C:\MSVCDev\CubicSDR_win64\x64 directory where CubicSDR can find it.

librtlsdr

  • Clone or download https://github.com/librtlsdr/librtlsdr to C:\MSVCDev\librtlsdr
  • Launch CMake, set source path to C:/MSVCDev/librtlsdr/
  • Set destination to C:/MSVCDev/librtlsdr_win64/
  • Click "Configure" and choose "Visual Studio 15 2017 Win64" and Finish
  • Set LIBUSB_INCLUDE_DIR to C:/MSVCDev/libusb-release/libusb-1.0/include
  • Set LIBUSB_LIBRARIES to C:/MSVCDev/libusb-release/MS64/dll/libusb-1.0.lib
  • Set THREADS_PTHREADS_INCLUDE_DIR to C:/MSVCDev/pthreads-win32/include
  • Set THREADS_PTHREADS_WIN32_LIBRARY to C:/MSVCDev/pthreads-win32/lib/x64/pthreadVC2.lib
  • Click "Configure" again and then click "Generate"

Open "Developer Command Prompt for VS2017" by right-clicking and "Run as Administrator".

From the prompt:

C:\> cd C:\MSVCDev\
C:\MSVCDEV> cmake --build librtlsdr_win64 --config Release
... Bunch of building ...
    0 Error(s)

Copy the file rtlsdr.dll in the C:\MSVCDev\CubicSDR_win64\x64 directory where CubicSDR can find it.

SoapyRTLSDR

  • Clone or download ZIP from https://github.com/pothosware/SoapyRTLSDR to C:\MSVCDev\SoapyRTLSDR
  • Launch CMake, set source path to C:/MSVCDev/SoapyRTLSDR/
  • Set destination to C:/MSVCDev/SoapyRTLSDR_win64
  • Click "Configure" and choose "Visual Studio 15 2017 Win64" and Finish
  • Set CMAKE_INSTALL_PREFIX to C:/MSVCDev/SoapySDR_win64_install
  • Click "Configure" again
  • Set RTLSDR_INCLUDE_DIR to C:/MSVCDev/librtlsdr/include
  • Set RTLSDR_LIBRARY to C:/MSVCDev/librtlsdr_win64/src/Release/rtlsdr.lib
  • Click "Configure" again and then click "Generate"

Open "Developer Command Prompt for VS2017" by right-clicking and "Run as Administrator".

From the prompt:

C:\> cd C:\MSVCDev\
C:\MSVCDEV> cmake --build SoapyRTLSDR_win64 --config Release --target clean
... Bunch of messages ...
    0 Error(s)
C:\MSVCDEV> cmake --build SoapyRTLSDR_win64 --config Release --target install
... Bunch of building ...
    0 Error(s)

Copy the generated module file rtlsdrSupport.dll in the C:\MSVCDev\CubicSDR_win64\x64\modules directory where CubicSDR can find it.

SoapySDRPlay

  • First, download the "API/HW Driver v2.x" version (NOT the v3.x one !) from https://www.sdrplay.com/downloads/ and install it with defaults.
  • Clone or download ZIP from https://github.com/pothosware/SoapySDRPlay to C:\MSVCDev\SoapySDRPlay
  • Launch CMake, set source path to C:/MSVCDev/SoapySDRPlay
  • Set destination to C:/MSVCDev/SoapySDRPlay_win64
  • Click "Configure" and choose "Visual Studio 15 2017 Win64" and Finish
  • Set CMAKE_INSTALL_PREFIX to C:/MSVCDev/SoapySDR_win64_install
  • Click "Configure" again
  • Set LIBSDRPLAY_INCLUDE_DIRS to C:/Program Files/SDRplay/API/inc
  • Set LIBSDRPLAY_LIBRARIES to C:/Program Files/SDRplay/API/x64/mir_sdr_api.lib
  • Click "Configure" again and then click "Generate"

Open "Developer Command Prompt for VS2017" by right-clicking and "Run as Administrator".

From the prompt:

C:\> cd C:\MSVCDev\
C:\MSVCDEV> cmake --build SoapySDRPlay_win64 --config Release --target clean
... Bunch of messages ...
    0 Error(s)
C:\MSVCDEV> cmake --build SoapySDRPlay_win64 --config Release --target install
... Bunch of building ...
    0 Error(s)

Copy the generated module file sdrPlaySupport.dll in the C:\MSVCDev\CubicSDR_win64\x64\modules directory where CubicSDR can find it.

Don't forget to also copy the C:\Program Files\SDRplay\API\x64\mir_sdr_api.dll library file in the C:\MSVCDev\CubicSDR_win64\x64 directory where CubicSDR can find it.

Debugging CubicSDR

Although all binaries are compiled in Release, it doesn't prevent debugging CubicSDR itself. All you need to do is re-compiling CubicSDR with particular configuration and options, as follows:

In Visual Studio, select the RelWithDebInfo configuration. Then go to CubicSDR subproject Configuration Properties => C++ => Optimization and modify the following options:

  • Optimization: Disabled (/Od)
  • Inline Function Expansion: Disabled (/Ob0)

This particular binary is generated in C:\MSVCDev\CubicSDR_win64\x64\RelWithDbInfo, so take care of copying all the Cubic resources (modules, fonts and additional libraries) in this directory so it can execute properly.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.