raspberrypi / rpi-imager

The home of Raspberry Pi Imager, a user-friendly tool for creating bootable media for Raspberry Pi devices.
https://www.raspberrypi.com/software
Other
1.61k stars 241 forks source link

Can't get OpenSSL detected on windows build #351

Closed guysoft closed 2 years ago

guysoft commented 2 years ago

Steps to reproduce:

  1. Install QT with minw81_32

  2. Install git bash and checkout this repo

  3. install Msys2 (64bit default)

  4. install cmake for windows from cmake.org

  5. Open Msys2 MingMW and run the following to get the 32bit dlls:

    pacman -S mingw-w64-i686-toolchain
  6. Extract from the path C:\msys64\mingw32\bin : libssl-1_1.dll, libcrypto-1_1.dll and openssl.exe and copy them to: C:\Qt\5.15.2\mingw81_32\

  7. create a build folder in rpi-imager source folder, cd in to it and run cmake ..

The error is:

CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY) (found
  version "1.1.1i")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
-- Configuring incomplete, errors occurred!
  C:/Program Files/CMake/share/cmake-3.22/Modules/FindOpenSSL.cmake:574 (find_package_handle_standard_args)
See also "D:/a/pi-imager/pi-imager/build/CMakeFiles/CMakeOutput.log".
  CMakeLists.txt:115 (find_package)

I also get the same error in this github action: https://github.com/guysoft/pi-imager/blob/windows-ci/.github/workflows/build-windows.yml

How do I get OpenSSL to be recognized?

maxnet commented 2 years ago

Out of the top of my head:

guysoft commented 2 years ago

@maxnet

Perhaps I need to set the paths to be windows or unix? It should find those.

guysoft commented 2 years ago

Ok, one more clue - it looks like it is finding the settings, because if I only run cmake .. it says its finding OpenSSL version 1.1.1i, but if I do set it it find version 1.1.1m, which is the one provided by mingw-w64-i686-toolchain

maxnet commented 2 years ago

Building can be done manually using the command-line, using "cmake", "make", etc., but if you are not that familar with setting up a proper Windows build environment (setting paths, etc.), it is easiest to use the Qt creator GUI instead.

Is in the README for a reason. There are more paths you need to worry about than just OpenSSL if you are not using Qt Creator which comes with nice defaults.

guysoft commented 2 years ago
maxnet commented 2 years ago

I understand and would have preferred to build openssl (no idea how to automate manual signing)

I am personally not a big fan of building applications automated in the cloud either. By signing it you are pretty much saying that you are vouching for the integrity of the build. And I trust the integrity of my local build virtual machine -that is not used for anything else than compiling stuff- more than a virtual machine at some cloud provider. I have no way of knowing how many of their staff members have access too...

Anyway, to answer your question.

but I also got stuck building openssl, there was some compile error command (perhaps it might help to show this?):

I am afraid I do not have time to provide detailed assistance on how to setup a Qt build environment with OpenSSL. But the general idea is:

guysoft commented 2 years ago

I managed manually to get it to build with those ssl libs by

  1. commenting out:
    # find_package(OpenSSL REQUIRED)
  2. Adding at the end:
    set(OPENSSL_INCLUDE_DIR "C:/msys64/mingw32/include")
    set(OPENSSL_LIBRARIES "C:/msys64/mingw32/lib/libssl.a" "C:/msys64/mingw32/lib/libcrypto.a")

    NOTE THE SLASHES ARE REVERSED

I also had to remove signtool.exe (I have it at C:\Program Files (x86)\Windows Kits\10\bin\x64):

    # Code signing
    # find_program(SIGNTOOL "signtool.exe" PATHS "c:/Program Files (x86)/Microsoft SDKs/ClickOnce/SignTool")
    # if (NOT SIGNTOOL)
    #     message(FATAL_ERROR "Unable to locate signtool.exe used for code signing")
    # endif()

Then it builds and runs

I could not get it to detect OpenSSL otherwise

guysoft commented 2 years ago

Just saw your other message: Thanks for giving me direction so far. ATM I want some form of ci/cd for the fork, so I am going to hopefully make it build without any signature and have something people can play with. Afterwards I can look in to signing and other stuff assuming this matures to be a fork by its own right.