Search code examples
cgccmingwcross-platformconan

Conan cannot find a certain package for the specified settings, options and dependencies


I am working on a small C executable project using Jetbrains CLion 2019.3, MinGW 8.1, and also the Conan C/C++ Package Manager 1.21.1. I am refreshing my knowledge about C and want to learn about new tools like Conan. My main development environment is Windows, but this project is intended to be cross-platform; I would like to be able to build and run the application on Linux/Unix as well.

Since my application needs to compute signatures using HMACSHA1, I want to use the OpenSSL library, so I added the OpenSSL/1.1.1a@conan/stable package to the requires section of my conanfile.txt file, and I also created a Conan profile for MinGW that has the following options:

toolchain=$MINGW64_PATH
target_host=x86_64-w64-mingw32
cc_compiler=gcc
cxx_compiler=g++

[env]
CONAN_CMAKE_FIND_ROOT_PATH=$toolchain
CHOST=$target_host
AR=$target_host-ar
AS=$target_host-as
RANLIB=$target_host-ranlib
CC=$target_host-$cc_compiler
CXX=$target_host-$cxx_compiler
STRIP=$target_host-strip
RC=$target_host-windres

[settings]
os_build=Windows
arch_build=x86_64

# We are cross-building to Windows
os=Windows
arch=x86_64
compiler=gcc

# Adjust to the gcc version of your MinGW package
compiler.version=8.1
compiler.libcxx=libstdc++11
build_type=Release

The MINGW64_PATH points to my MinGW installation folder.

When running conan install it complains about a missing package (obviously a dependency package of OpenSSL) that does not exist:

zlib/1.2.11@conan/stable: WARN: Can't find a 'zlib/1.2.11@conan/stable' package for the specified settings, options and dependencies:
- Settings: arch=x86_64, build_type=Release, compiler=gcc, compiler.version=8.1, os=Windows
- Options: minizip=False, shared=False
- Dependencies: 
- Package ID: eb34f13b437ddfd63abb1f884c4b8886c48b74cd

ERROR: Missing prebuilt package for 'zlib/1.2.11@conan/stable'
Try to build it from sources with "--build zlib"
Or read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-missing-prebuilt-package"

Since I am a noob using Conan, I have no clue how I can fix this problem. What needs to be done to fix this issue, and also can I fix this on my own, or do I need help from the package author?

I found a description of the Missing prebuilt package error at https://docs.conan.io/en/latest/faq/troubleshooting.html#error-missing-prebuilt-package, but it does not help much.


Solution

  • so I added the OpenSSL/1.1.1a@conan/stable package to the requires

    That package is obsolete, you can check it on Conan Community repository. You should try openssl/1.1.1a@ instead, which is maintained by the new Conan Center Index.

    conan install openssl/1.1.1d@
    

    Where is the namespace? It has been removed, take a look on more information about recipes.

    Since I am a noob using Conan, I have no clue how I can fix this problem. What needs to be done to fix this issue, and also can I fix this on my own, or do I need help from the package author?

    As the FAQ recommends, you should build by yourself, running the command proposed by the error message:

    conan install openssl/1.1.1a@ --build zlib
    

    But I'm sure it won't be enough, you will need to build OpenSSL too. So, the best approach in your situation is:

    conan install openssl/1.1.1a@ --build missing
    

    Now, Conan will build from sources anything which is not pre-built on server side.

    To summarize, this is not an error, like something is broken.

    When you asked for OpenSSL 1.1.1a, Conan found the recipe on Conan Center, which explain how to build OpenSSL, however it didn't find your pre-built package, following your settings and options.

    Well, MingW is not used in Conan Center Index, because there is no enough demand, all supported platforms and configurations are listed in the Wiki. But this specific recipe should support MingW, since when it was part of Conan Community, MingW was present in package lists for building.

    I would say, you can use 1.1.1d instead, which newer and safer than 1.1.1a.