Search code examples
static-librariesstatic-linkingconanconan-2

Conan: How to get the exact version of a statically linked library contained in a pre-built package?


I used the following command to get a list of pre-built packages for the libpng library:

conan download libpng/1.6.40 -p "arch=x86_64 AND os=Windows AND compiler=msvc AND compiler.version=192" -r conancenter -f json

Besides other information, I get the following info:

                        "requires": [
                                "zlib/1.3.Z"
                            ]
                        }

I get the path to the downloaded pre-built package like this: conan cache path libpng/1.6.40:2dc71d849fb2a3eea8f4b3bf24e7117c93b68a8a (the last part being the package id from the conan download output).

How can I find out which exact version of zlib was used to build this pre-built libpng .lib file? The conan download information just gives me a Z for the last part of the version.

I also looked into conan graph info command, but couldn't figure out if this can help me.


Solution

  • Conan packages do not contain by default the declaration of the exact version and revision that the binary used to link. The "zlib/1.3.Z" that is being listed is the "binary compatibility" declaration, saying that this built binary can be used with any patch version of zlib/1.3 without necessarily recompiling itself.

    If you want to store an exact copy of the dependencies versions when building a package, it can be done with:

    • Modifying a recipe, you can generate a file in your preferred format iterating self.dependencies. This might be done in the generate() method if you want to do it pre-build, or during the build() or even in the package() method. Using something like dep.ref, read this section
    • Without modifying the recipe, and applying it to all packages being built, you can add the same logic as above, but inside a hook (read this section). A post/pre generate/build/package might be ok for this.