This repo showcases cpack failure when consuming conan v2 packages with transient dependencies.
All dependencies are built as shared libs.
subproject
directory contains a custom conan v2 example package to reproduce the problem.
This project also allows testing this same problem on conan v1 systems, however subproject
package can not be built because test_package
is failing. For some reason, libEXAMPLE_REST_Utility.so
can not be found, even thought it is linked in. You can see this behavior by running the following:
docker build -t conan_v1_create_failure subproject/
docker run conan_v1_create_failure
- Create sub-project package with:
conan create subproject/ --version=0.0.0 --build=missing
- Create build directory and change into it with:
mkdir build && cd build
- Call conan install command and generate CMake build scripts. (Cmake internally uses conan_provider.cmake to read conanfile.txt, which tells conan what packages to download and install)
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_NANODBC=OFF -DWITH_CURL=OFF -DWITH_SUBPROJECT=ON ..
- Build the code
cmake --build . --target all --config Debug --
- Run the executable to make sure it works
./sources/conan2_pkg_test_Runner
- Try to create a simple package
cpack -G TGZ
On debian bookworm this fails to find cassandra-cpp-driver
package from the subproject:
CPack: Create package using TGZ
CPack: Install projects
CPack: - Run preinstall target for: conan2_pkg_test
CPack: - Install project: conan2_pkg_test []
CMake Error at /conan2_pkg_test/build/sources/cmake_install.cmake:66 (file):
file Could not resolve runtime dependencies:
libcassandra.so.2
Call Stack (most recent call first):
/conan2_pkg_test/build/cmake_install.cmake:47 (include)
CPack Error: Error when generating package: conan2_pkg_test
Same behavior can be seen when using nanodbc
package. Clean the build directory with:
rm -rf build/* && cd build
and reconfigure the project to only use nanodbc
package with:
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_NANODBC=ON -DWITH_CURL=OFF -DWITH_SUBPROJECT=OFF ..
Then re-run the steps 4-6 and get the following:
Pack: Create package using TGZ
CPack: Install projects
CPack: - Run preinstall target for: conan2_pkg_test
CPack: - Install project: conan2_pkg_test []
CMake Error at /conan2_pkg_test/build/sources/cmake_install.cmake:66 (file):
file Could not resolve runtime dependencies:
libiconv.so.2
libltdl.so.7
Call Stack (most recent call first):
/conan2_pkg_test/build/cmake_install.cmake:47 (include)
CPack Error: Error when generating package: conan2_pkg_test
This is really similar to how subproject transient dependencies fail to be resolved by cmake_install.cmake
. nanodbc
package depends on odbc
package, which in turn depends on libtool
and libiconv
packages. libiconv.so
comes from libiconv
package and libltdl.so
comes from libtool
package.
Even stranger things happen when we try to package projects with libcurl
dependency. Similar to as before Clean the build directory with:
rm -rf build/* cd build
and reconfigure the project to only use libcurl
package with:
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_NANODBC=OFF -DWITH_CURL=ON -DWITH_SUBPROJECT=OFF ..
Then re-run the steps 4-6 and get the following:
CPack: Create package using TGZ
CPack: Install projects
CPack: - Run preinstall target for: conan2_pkg_test
CPack: - Install project: conan2_pkg_test []
CMake Error at /conan2_pkg_test/build/sources/cmake_install.cmake:66 (file):
file Multiple conflicting paths found for libcrypto.so.3:
/lib/x86_64-linux-gnu/libcrypto.so.3
/root/.conan2/p/b/opens6b2fbd1f2b289/p/lib/libcrypto.so.3
Call Stack (most recent call first):
/conan2_pkg_test/build/cmake_install.cmake:47 (include)
CPack Error: Error when generating package: conan2_pkg_test
For some reason, cmake sees both the libcrypto.so.3
that comes from openssl
package and the one that comes from the system.
Build docker images with
docker build -t conan_example --build-arg CONAN_VERSION=2.0.10 --build-arg USE_NANODBC=ON --build-arg USE_CURL=ON --build-arg USE_SUBPROJECT=ON .
or to use provided defaults (conan v2.0.10, nanodbc off, curl off, subproject ON)
docker build -t conan_example .
And run it with:
docker run conan_example
or run it in interactive mode with:
docker run -it conan_example bash