-1

I'm trying to use OpenSSL with Flutter using dart:ffi, but when i run the project on Ubuntu 20.04 the error message as below comes out. I tested the project on Windows 10 and it worked.

Project repository

CMakeLists.txt

cmake_minimum_required(VERSION 3.6)
project(flutter_openssl_crypto)

find_package(openssl REQUIRED CONFIG)

add_library(${PROJECT_NAME} SHARED empty.c)
target_link_libraries(${PROJECT_NAME} PRIVATE openssl::crypto)

Error

CMakeLists.txt:6 (find_package):
    Could not find a package configuration file provided by "openssl" with any
    of the following names:                                             
                                                                        
      opensslConfig.cmake                                               
      openssl-config.cmake                                              
                                                                        
    Add the installation prefix of "openssl" to CMAKE_PREFIX_PATH or set
    "openssl_DIR" to a directory containing one of the above files.  If 
    "openssl" provides a separate development package or SDK, be sure it has
    been installed.                                                     
                                                                        
                                                                        
* Try:                                                                  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
                                                                        
* Get more help at https://help.gradle.org                              
                                                                        
BUILD FAILED in 4s                                                      
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                         5.3s
Exception: Gradle task assembleDebug failed with exit code 1

How can i run the project on Ubuntu?

  • Have you installed `libssl-dev` package, as suggested in [that answer](https://stackoverflow.com/a/27551158/3440745)? Actually, OpenSSL provided by the package manager doesn't contain listed config scripts, which are needed for `CONFIG` mode of `find_package`. Remove `CONFIG` option, you build and install OpenSSL **from sources**: that installation will contain required files. – Tsyvarev Oct 18 '21 at 14:22
  • Thanks for the answer. I have installed `libssl-dev` package. I'm using OpenSSL from Google Maven Repository, OpenSSL is download during the project build. On Windows no extra configurations are necessary, just download the project, and flutter sdk, but not on Ubuntu. – Cadu Gomes Oct 18 '21 at 14:36
  • My previous comment misses some words. I meant the you have two variants on Ubuntu: 1. Use OpenSSL provided by the package manager (`libssl-dev`), but remove `CONFIG` option and update usage of targets according to the [documentation](https://cmake.org/cmake/help/latest/module/FindOpenSSL.html). 2. Build and install OpenSSL from source. That installation will contain files required for `CONFIG` mode. – Tsyvarev Oct 18 '21 at 14:45
  • It means i don't have a variant using the Google Maven Repository? It's the most easy way to use OpenSSL with Flutter – Cadu Gomes Oct 18 '21 at 16:23

1 Answers1

0

I found the problem. I had installed Android Studio and Flutter SDK for Ubuntu software, that's the problem. When I reinstalled both from the official websites, the project work's.