64 Build Windows
Charles J. Cliffe edited this page 2024-01-25 18:43:39 -05:00

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 2022, it works also for either 2019, 2017, or even 2015. The 2022 version is the last iteration of the 2015 generation, so use this one preferably. Visual Studio 2022 also has better compiler optimizations which may result a faster CubicSDR.

Interesting point, VS 2022 produces binaries compatible with earlier 2015 / 2017 / 2019 versions so there is no point of not using VS 2022 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 2022

If you don't already have Visual Studio 2022 you can install the free Microsoft "Visual Studio Community 2022" 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.2.1/wxWidgets-3.2.1.zip and unzip it to somewhere such as C:\MSVCDev\wxWidgets

Navigate to C:\MSVCDev\wxWidgets\build\msw (or wherever you extracted) and open wx_vc17.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

This guide use the CMake GUI. Take care of uncheck the Grouped option first !

Download CMake from:

For this guide I've used v3.25.1 found here:

Install SoapySDR

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

  • Launch CMake GUI, source path to C:/MSVCDev/SoapySDR/
  • Set destination to C:/MSVCDev/SoapySDR_win64/
  • Click Configure.
  • Choose "Visual Studio 17 2022" as Specify the generator for this project and "x64" as Optional platform for generator then click 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 "x64 Native Tools Command Prompt for VS 2022" 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)

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

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 17 2022" as Specify the generator for this project and "x64" as Optional platform for generator then click Finish.
  • Set wxWidgets_ROOT_DIR to C:\MSVCDev\wxWidgets
  • Click "Configure" again
  • Set SoapySDR_DIR to C:/MSVCDev/SoapySDR_win64_install/cmake
  • 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-4.dll
  • Set HAMLIB_INCLUDE_DIR to C:/MSVCDev/CubicSDR/external/hamlib
  • Set HAMLIB_LIBRARY to C:/MSVCDev/CubicSDR/external/hamlib/64/libhamlib-4.lib
  • Set LIQUID_DLL to C:/MSVCDev/CubicSDR/external/liquid-dsp/msvc/64/libliquid.dll
  • Set LIQUID_INCLUDES to C:/MSVCDev/CubicSDR/external/liquid-dsp/include
  • Set LIQUID_LIBRARIES to C:/MSVCDev/CubicSDR/external/liquid-dsp/msvc/64/libliquid.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_2019.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/rtlsdrblog/rtl-sdr-blog-minimal to C:\MSVCDev\librtlsdr
  • Launch CMake, set source path to C:/MSVCDev/librtlsdr/
  • Set destination to C:/MSVCDev/librtlsdr_win64/
  • Click Configure.
  • Choose "Visual Studio 17 2022" as Specify the generator for this project and "x64" as Optional platform for generator then click 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 "x64 Native Tools Command Prompt for VS 2022" 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.
  • Choose "Visual Studio 17 2022" as Specify the generator for this project and "x64" as Optional platform for generator then click Finish.
  • Set SoapySDR_DIR to C:/MSVCDev/SoapySDR_win64_install/cmake
  • 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 "x64 Native Tools Command Prompt for VS 2022" 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
... 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, go to https://www.sdrplay.com/downloads/, select your device and Windows version of choice, and go to the "API" download section : choose the "API/HW Driver 3.x" version and install it with defaults.
  • Clone or download ZIP from https://github.com/SDRplay/SoapySDRPlay to C:\MSVCDev\SoapySDRPlay
  • Launch CMake, set source path to C:/MSVCDev/SoapySDRPlay
  • Set destination to C:/MSVCDev/SoapySDRPlay_win64
  • Click Configure.
  • Choose "Visual Studio 17 2022" as Specify the generator for this project and "x64" as Optional platform for generator then click Finish.
  • Set SoapySDR_DIR to C:/MSVCDev/SoapySDR_win64_install/cmake
  • Click "Configure" again
  • Set LIBSDRPLAY_INCLUDE_DIRS to C:\Program Files\SDRplay\API\inc
  • Set LIBSDRPLAY_LIBRARIES to C:\Program Files\SDRplay\API\x64\sdrplay_api.lib
  • Set RF_GAIN_IN_MENU to 1 (checked)
  • Click "Configure" again and then click "Generate"

Open "x64 Native Tools Command Prompt for VS 2022" 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
... 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\sdrplay_api.dll library file in the C:\MSVCDev\CubicSDR_win64\x64 directory where CubicSDR can find it.

Notes:

  • After installing the API driver v3.x for the first time, you may need to reboot your computer to have your device detected properly.
  • Sometimes the device detection fails in CubicSDR : you can then restart the driver by running RestartService.bat (Right-Click > Run as Administrator) located in C:\Program Files\SDRplay\

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.