rnpgp / rnp

RNP: high performance C++ OpenPGP library used by Mozilla Thunderbird
https://www.rnpgp.org
Other
201 stars 55 forks source link

CMake errors while building on Windows 10 #1927

Closed wyatt-sfu closed 2 years ago

wyatt-sfu commented 2 years ago

Description

While following the Windows build instructions in https://github.com/rnpgp/rnp/blob/master/docs/installation.adoc I am getting CMake failures with a couple of different error messages.

Steps to Reproduce

  1. Download and unzip rnp-0.16.2
  2. Install vcpkg with git clone https://github.com/Microsoft/vcpkg.git
  3. Install packages with vcpkg install bzip2 zlib botan json-c getopt dirent python3[core]
  4. Run cmake -B . -G "Visual Studio 16 2019" -A x64 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Release ../rnp

Versions

Results

CMake output: rnp_cmake_error.txt I have attached the CMake log as well: CMakeOutput.log vcpkg list: vcpkg_list.txt

A snippet from the output is:

CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find JSON-C (missing: JSON-C_LIBRARY JSON-C_INCLUDE_DIR
  JSON-C_VERSION) (Required is at least version "0.11")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  cmake/Modules/FindJSON-C.cmake:92 (find_package_handle_standard_args)
  C:/dev/vcpkg_rnp/scripts/buildsystems/vcpkg.cmake:834 (_find_package)
  src/lib/CMakeLists.txt:33 (find_package)
ni4 commented 2 years ago

@wyatt-sfu possibly you are missing VCPKG_DIR environment variable. From the windows-msvc.yml GitHub workflow (which builds and works fine):

      - name: Configure
        env:
          VCPKG_DIR: '${{ matrix.vcpkg_dir }}'
        shell: bash
        run: |
          set -eux
          mkdir build
          cmake -B ./build -G "Visual Studio 16 2019" -A ${{ matrix.arch }} -DCMAKE_TOOLCHAIN_FILE=${{ matrix.vcpkg_dir }}\\scripts\\buildsystems\\vcpkg.cmake .
      - name: Compile
        shell: bash
        run: cmake --build ./build --config "Release" -j 2
wyatt-sfu commented 2 years ago

@ni4 I think I have figured out the issue. I did not need a VCPKG_DIR environment variable because the build tutorial uses VCPKG_ROOT.

However, the trick was to specify the x64-windows triplet when installing the VCPKG packages. So rather than vcpkg install bzip2 zlib botan json-c getopt dirent python3[core], I instead ran, vcpkg install bzip2:x64-windows zlib:x64-windows botan:x64-windows json-c:x64-windows getopt:x64-windows dirent:x64-windows python3[core]:x64-windows After this change, then running cmake and building rnp seems to have worked fine. I can run rnp.exe and rnpkeys.exe.

ni4 commented 2 years ago

Thanks for writing back! Definitely, workflow has this line as well: vcpkg install --triplet ${{ matrix.triplet }} $(cat vcpkg.txt). PR #1928 should update the documentations.

wyatt-sfu commented 2 years ago

Thanks for the quick responses!