Search code examples
conan

Conan for consuming a dependency seems to not work in conanfile.txt


Firstly I know this question is been asked for a while among various channels but since I am very new to conan there are things I still don't understand even after reading other answers and posts. We have a task in our project where we need to use a third party library gdal to be installed. Hence my conanfile.txt looked like this:

[requires]
libexif/0.6.23
sdl/2.0.20
nlohmann_json/3.10.5 
yaml-cpp/0.6.3
gdal/3.4.3
openssl/1.1.1o
libjpeg-turbo/2.0.5

[generators]
cmake_find_package
cmake_paths

Now after running conan install I encountered following issue :

*ERROR: At least two recipes provides the same functionality:
 - 'libjpeg' provided by 'libjpeg-turbo/2.0.5', 'libjpeg/9d'

After searching online for results, it leads to this page https://docs.conan.io/en/1.46/reference/conanfile/attributes.html where they said to use "Provides" in order to distinguish recipes providing same functionality. But what i don't understand is that I am not using a conanfile.py (which is a recipe). The conanfile.txt is similar to requirements file and unfortunately we don't want to make it complex as none in our team are familiar with conan so we are trying to find a way to fix it in conanfile.txt. Thanks a lot for the help


Solution

  • With following command you can check what requires the libjpeg: conan info gdal/3.4.3@

    From the output you can see that gdal and libtiff (libtiff is required by gdal) both require libjpeg:

    libjpeg/9d
    ...
        Required by:
            gdal/3.4.3
            libtiff/4.3.0
    

    So you need to use the options to switch jpeg implementation for both libtiff and gdal as follows:

    [requires]
    ...
    
    [generators]
    ...
    
    [options]
    gdal:with_jpeg=libjpeg-turbo
    libtiff:jpeg=libjpeg-turbo