This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

pc-ble-driver cannot be built with current instructions

The instructions at https://github.com/NordicSemiconductor/pc-ble-driver do not allow building the driver or the examples on a Windows system.  Following the instructions takes you to a point where you create a "build" subdirectory, run cmake --G Ninja .. , then run cmake --build . 

Unfortunately, there are a significant number of assumptions built into the instructions that make the first of these two statements fail:

1) CMAKE_C_COMPILER needs to be set manually - the instructions fail to do this

2) CMAKE_CXX_COMPILER needs to be set manually - the instructions fail to do this

3) CMakeLists.txt needs to be edited to include a line setting ASIO_INCLUDE_DIR to the "include" directory under the vcpkg asio subdirectory installed in a previous step

4) Despite assertions by the build system that something similar needs to be done for spdlog ("CMake Error at test/CMakeLists.txt:11 (find_package):
  Could not find a package configuration file provided by "spdlog" with any
  of the following names:

    spdlogConfig.cmake
    spdlog-config.cmake

  Add the installation prefix of "spdlog" to CMAKE_PREFIX_PATH or set
  "spdlog_DIR" to a directory containing one of the above files.  If "spdlog"
  provides a separate development package or SDK, be sure it has been
  installed."
this assertion is FALSE - adding a line to CMakelists.txt to set either spdlog_DIR or CMAKE_PREFIX_PATH to include the spdlog directory fail with the same error

It would be extremely helpful if the instructions could actually be followed to allow this package to be built.

  • Hi Pierre,

    Thanks for reporting this. I have forwarded this to the pc-ble-driver developers.

  • So I finally figured this out.  Short answer: NONE of the above installers correctly update the necessary environment variables for Windows.  You need to go into the system environment variables and do the following:

    1) Add the following to PATH: c:\cmake\bin; c:\program files\git\bin; c: \program files (x86)\Microsoft Visual Studio 10.0\VC\bin

    2) Set CMAKE_C_COMPILER to "cl.exe" and CMAKE_CXX_COMPILER to "cl.exe"

    3) Set ASIO_INCLUDE_DIR to the include directory you created during VCPKG install at ...\vcpkg\packages\asio_x64-windows\include

    4) Set spdlog_DIR to the include directory you created during VCPKG install at ...\vcpkg\packages|spdlog_x64-windows\share\spdlog

    5) in CMakeLists.txt, make sure that you add the path to spdlog to CMAKE_PREFIX_PATH, e.g. set (CMAKE_PREFIX_PATH "c:/projects/vcpkg/spdlog_65-windows:${CMAKE_PREFIX_PATH}")

  • On macOS there are similar issues, with a bit different resolution:

    export spdlog_DIR=/usr/local/var/vcpkg/packages/spdlog_x64-osx
    export fmt_DIR=/usr/local/var/vcpkg/packages/fmt_x64-osx
    export Catch2_DIR=/usr/local/var/vcpkg/packages/catch2_x64-osx
    
    cmake -G Ninja -DCOMPILE_CONNECTIVITY=1 -DCONNECTIVITY_VERSION=4.1.4 -DNRF_BLE_DRIVER_VERSION=4.1.4 -DASIO_INCLUDE_DIR=/usr/local/var/vcpkg/packages/asio_x64-osx/include ..

    And make sure to have GNUARMEMB_TOOLCHAIN_PATH pointing to gcc-arm-none-eabi-7-2018-q2-update

Related