Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] conan 2.x: linking against a shared lib with private shared dependencies fails on Linux (again) #13560

Closed
SpaceIm opened this issue Mar 29, 2023 · 20 comments · Fixed by #16964
Milestone

Comments

@SpaceIm
Copy link
Contributor

SpaceIm commented Mar 29, 2023

Environment details

  • Operating System+version: Ubuntu 22.04
  • Compiler+version: gcc 12.1.0
  • Conan version: 2.0.2
  • Python version: 3.10.6

Steps to reproduce

conan install --requires="libzippp/6.0-1.9.2" -o "*:shared=True" -b missing

Logs

build log
libzippp/6.0-1.9.2: Building from source
libzippp/6.0-1.9.2: Package libzippp/6.0-1.9.2:ee3488ab65102991abf5b636e39de538d8d3e7ab
libzippp/6.0-1.9.2: Copying sources to build folder
libzippp/6.0-1.9.2: Building your package in /home/spaceim/.conan2/p/t/libzic30b1ebec828d/b
libzippp/6.0-1.9.2: Calling generate()
libzippp/6.0-1.9.2: Generators folder: /home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/build/Release/generators
libzippp/6.0-1.9.2: CMakeToolchain generated: conan_toolchain.cmake
libzippp/6.0-1.9.2: CMakeToolchain generated: CMakePresets.json
libzippp/6.0-1.9.2: CMakeToolchain generated: ../../../src/CMakeUserPresets.json
libzippp/6.0-1.9.2: Generating aggregated env files
libzippp/6.0-1.9.2: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
libzippp/6.0-1.9.2: Calling build()
libzippp/6.0-1.9.2: Running CMake.configure()
libzippp/6.0-1.9.2: RUN: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/build/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/spaceim/.conan2/p/t/libzic30b1ebec828d/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src"
-- Using Conan toolchain: /home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: Setting BUILD_SHARED_LIBS = ON
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc-12 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++-12 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Component target declared 'libzip::zip'
-- Conan: Target declared 'ZLIB::ZLIB'
-- Conan: Target declared 'BZip2::BZip2'
-- Conan: Including build module from '/home/spaceim/.conan2/p/bzip2b4101dd1d9e37/p/lib/cmake/conan-official-bzip2-variables.cmake'
-- Conan: Target declared 'LibLZMA::LibLZMA'
-- Conan: Including build module from '/home/spaceim/.conan2/p/xz_utae9210766e49b/p/lib/cmake/conan-official-xz_utils-variables.cmake'
-- Conan: Component target declared 'zstd::libzstd_shared'
-- Conan: Component target declared 'OpenSSL::Crypto'
-- Conan: Component target declared 'OpenSSL::SSL'
-- Conan: Target declared 'openssl::openssl'
-- Conan: Including build module from '/home/spaceim/.conan2/p/opens3b56123e737a3/p/lib/cmake/conan-official-openssl-variables.cmake'
-- Configuring done (5.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/build/Release

libzippp/6.0-1.9.2: Running CMake.build()
libzippp/6.0-1.9.2: RUN: cmake --build "/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/build/Release" -- -j8
[1/4] Building CXX object CMakeFiles/libzippp.dir/src/libzippp.cpp.o
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/src/libzippp.cpp: In function ‘void defaultErrorHandler(const std::string&, const std::string&, int, int)’:
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/src/libzippp.cpp:127:37: warning: unused parameter ‘zip_error_code’ [-Wunused-parameter]
  127 |                                 int zip_error_code,
      |                                 ~~~~^~~~~~~~~~~~~~
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/src/libzippp.cpp:128:37: warning: unused parameter ‘system_error_code’ [-Wunused-parameter]
  128 |                                 int system_error_code)
      |                                 ~~~~^~~~~~~~~~~~~~~~~
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/src/libzippp.cpp: In function ‘void progress_callback(zip*, double, void*)’:
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/src/libzippp.cpp:350:29: warning: unused parameter ‘archive’ [-Wunused-parameter]
  350 | void progress_callback(zip* archive, double progression, void* ud) {
      |                        ~~~~~^~~~~~~
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/src/libzippp.cpp: In function ‘int progress_cancel_callback(zip*, void*)’:
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/src/libzippp.cpp:359:35: warning: unused parameter ‘archive’ [-Wunused-parameter]
  359 | int progress_cancel_callback(zip *archive, void *ud) {
      |                              ~~~~~^~~~~~~
[3/4] Building CXX object CMakeFiles/libzippp_test.dir/tests/tests.cpp.o
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/tests/tests.cpp: In function ‘void test21()’:
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/tests/tests.cpp:678:45: warning: the address of ‘int fflush(FILE*)’ will never be NULL [-Waddress]
  678 |     cout << "Running test 21..." << endl << fflush;
      |                                             ^~~~~~
In file included from /usr/include/c++/12/cstdio:42,
                 from /usr/include/c++/12/ext/string_conversions.h:43,
                 from /usr/include/c++/12/bits/basic_string.h:3960,
                 from /usr/include/c++/12/string:53,
                 from /usr/include/c++/12/bits/locale_classes.h:40,
                 from /usr/include/c++/12/bits/ios_base.h:41,
                 from /usr/include/c++/12/ios:42,
                 from /usr/include/c++/12/ostream:38,
                 from /usr/include/c++/12/iostream:39,
                 from /home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/tests/tests.cpp:38:
/usr/include/stdio.h:230:12: note: ‘int fflush(FILE*)’ declared here
  230 | extern int fflush (FILE *__stream);
      |            ^~~~~~
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/tests/tests.cpp: In function ‘int main(int, char**)’:
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/tests/tests.cpp:895:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
  895 | int main(int argc, char** argv) {
      |          ~~~~^~~~
/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/src/tests/tests.cpp:895:27: warning: unused parameter ‘argv’ [-Wunused-parameter]
  895 | int main(int argc, char** argv) {
      |                    ~~~~~~~^~~~
[4/4] Linking CXX executable libzippp_shared_test
FAILED: libzippp_shared_test
: && /usr/bin/g++-12 -W -Wall -Wextra -ansi -pedantic -std=c++11 -O3 -m64 CMakeFiles/libzippp_test.dir/tests/tests.cpp.o -o libzippp_shared_test  -Wl,-rpath,/home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/build/Release  libzippp.so && :
/usr/bin/ld: warning: libcrypto.so.1.1, needed by /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `EVP_aes_128_ecb@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `PKCS5_PBKDF2_HMAC_SHA1@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `HMAC_CTX_new@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `EVP_sha1@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `HMAC_Final@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `EVP_aes_192_ecb@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `HMAC_Init_ex@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `EVP_EncryptUpdate@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `HMAC_CTX_free@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `EVP_CIPHER_CTX_new@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `EVP_EncryptInit_ex@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `EVP_aes_256_ecb@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `EVP_CIPHER_CTX_free@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `RAND_bytes@OPENSSL_1_1_0'
/usr/bin/ld: /home/spaceim/.conan2/p/libzi1690beeedfbba/p/lib/libzip.so.5: undefined reference to `HMAC_Update@OPENSSL_1_1_0'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

libzippp/6.0-1.9.2: ERROR:
Package 'ee3488ab65102991abf5b636e39de538d8d3e7ab' build failed
libzippp/6.0-1.9.2: WARN: Build folder /home/spaceim/.conan2/p/t/libzic30b1ebec828d/b/build/Release
*********************************************************
Recipe 'libzippp/6.0-1.9.2' cannot build its binary
It is possible that this recipe is not Conan 2.0 ready
If the recipe comes from ConanCenter check: https://conan.io/cci-v2.html
If it is your recipe, check if it is updated to 2.0
*********************************************************

ERROR: libzippp/6.0-1.9.2: Error in build() method, line 88
        cmake.build()
        ConanException: Error 1 while executing

related to #13000

If you dig into libzippp recipe, recipe of its dependency libzip, their upstream CMakeLists and how they are patched, you'll see that libzippp properly links to libzip::zip target defined in libzip recipe, and that openssl::crypto conan component of openssl recipe is properly appended to requires of this libzip::_libzip conan component in package_info() of libzip. Still, openssl crypto is missing in -rpath-link when linker tries to create libzippp shared lib.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Mar 29, 2023

Mmmhh actually it may be an issue of libzipp recipe instead. I see that linker errors occur while linking libzippp_shared_test executable to libzippp, and this part may not have been properly fixed to link to CMake target.

@SpaceIm SpaceIm closed this as completed Mar 29, 2023
@SpaceIm SpaceIm reopened this Mar 29, 2023
@SpaceIm
Copy link
Contributor Author

SpaceIm commented Mar 29, 2023

I re-open because looking at CMakeLists, it shouldn't have failed anyway. libzippp target builds fine, but when this target is linked into libzippp_shared_test, I guess something is not properly defined in libzip::zip target and therefore CMake doesn't understand that it must define -rpath-link with path to openssl since it's a dependency of libzip::zip.

@memsharded
Copy link
Member

I have just tested and it works.

There might be something else you have on your side that you are not reporting, for example cmake -G "Ninja", and Ninja generator is not used by default, so I guess you have some other configuration there that could be affecting (the Ninja thing in particular seems to be working fine here, but it is just a sign that there could be other factors.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Mar 29, 2023

Indeed, my global.conf is:

tools.cmake.cmaketoolchain:generator=Ninja
tools.info.package_id:confs=["tools.build:cflags", "tools.build:cxxflags", "tools.build:defines", "tools.build:exelinkflags", "tools.build:sharedlinkflags"]

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Mar 29, 2023

@memsharded there is a good chance that you can't reproduce this issue if the same openssl so version is installed on your Linux distribution.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Mar 30, 2023

I see a similar issue in a recipe not merged yet in conan center.

On Linux with this profile:

[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
build_type=Release

You have to ckeckout first conan-io/conan-center-index#16355 and call conan create --version 1.9.2 -o "*:shared=True" -tf "" -b missing
Then checkout conan-io/conan-center-index#16356 and call conan create . --version 2.0 -o "*:shared=True" -tf "" -b missing

You should see these errors (since it's related to link errors to coin-osi, you have less chance to inaverdently not reproduce the issue):

log
[154/228] Linking CXX executable Linux-x86_64-Release/openMVG_main_SfMInit_ImageListing
FAILED: Linux-x86_64-Release/openMVG_main_SfMInit_ImageListing
: && /usr/bin/g++-12 -m64 -O3 -m64    -rdynamic software/SfM/CMakeFiles/openMVG_main_SfMInit_ImageListing.dir/main_SfMInit_ImageListing.cpp.o -o Linux-x86_64-Release/openMVG_main_SfMInit_ImageListing -L/home/spaceim/.conan2/p/coin-3845f169e96b1/p/lib   -L/home/spaceim/.conan2/p/flann85ffc349c0928/p/lib   -L/home/spaceim/.conan2/p/lz4866193c7de915/p/lib -Wl,-rpath,/home/spaceim/.conan2/p/coin-3845f169e96b1/p/lib:/home/spaceim/.conan2/p/flann85ffc349c0928/p/lib:/home/spaceim/.conan2/p/lz4866193c7de915/p/lib:/home/spaceim/.conan2/p/t/openmd7aa827f21e26/b/build/Release/Linux-x86_64-Release:  Linux-x86_64-Release/libopenMVG_sfm.so.2.0  Linux-x86_64-Release/libopenMVG_exif.so  Linux-x86_64-Release/libopenMVG_system.so.2.0  Linux-x86_64-Release/libopenMVG_image.so.2.0  Linux-x86_64-Release/libopenMVG_geometry.so.2.0  /home/spaceim/.conan2/p/coin-3845f169e96b1/p/lib/libemon.so  Linux-x86_64-Release/libopenMVG_matching.so.2.0  Linux-x86_64-Release/libopenMVG_features.so.2.0  Linux-x86_64-Release/libopenMVG_stlplus.so  /home/spaceim/.conan2/p/flann85ffc349c0928/p/lib/libflann_cpp.so  /home/spaceim/.conan2/p/lz4866193c7de915/p/lib/liblz4.so  Linux-x86_64-Release/libopenMVG_multiview.so.2.0  Linux-x86_64-Release/libopenMVG_numeric.so.2.0  -Wl,-rpath-link,/home/spaceim/.conan2/p/t/openmd7aa827f21e26/b/build/Release/Linux-x86_64-Release && :
/usr/bin/ld: warning: libOsi.so.1, needed by /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::setColName(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::reducedCostFix(double, bool)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiRowCut::ub() const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::activateRowCutDebugger(double const*, bool)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::getNumIntegers() const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::getRowNames[abi:cxx11]()'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::deleteColNames(int, int)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::writeLpNative(_IO_FILE*, char const* const*, char const* const*, double, int, int, double, bool) const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::getColNames[abi:cxx11]()'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::getObjName[abi:cxx11](unsigned int) const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::getStrictColSolution()'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiRowCut::setRow(int, int const*, double const*, bool)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiRowCut::row() const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::getObjValue() const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiRowCut::OsiRowCut()'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::getFractionalIndices(double) const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::deleteBranchingInfo(int, int const*)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::setRowNames(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, int, int, int)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::~OsiSolverInterface()'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `typeinfo for OsiSOS'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::dfltRowColName[abi:cxx11](char, int, unsigned int) const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::deleteRowNames(int, int)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::findIntegers(bool)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiRowCut::setLb(double)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiRowCut::lb() const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::restoreBaseModel(int)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::setInitialData()'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::OsiSolverInterface()'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::writeMpsNative(char const*, char const**, char const**, int, int, double, int, CoinSet const*) const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiRowCut::setUb(double)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `typeinfo for OsiObject'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::OsiSolverInterface(OsiSolverInterface const&)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::setRowName(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::readGMPL(char const*, char const*)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `typeinfo for OsiSolverInterface'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::operator=(OsiSolverInterface const&)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSOS::OsiSOS(OsiSolverInterface const*, int, int const*, double const*, int)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::setColNames(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, int, int, int)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::setObjCoeffSet(int const*, int const*, double const*)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::newLanguage(CoinMessages::Language)'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::getApplicationData() const'
/usr/bin/ld: /home/spaceim/.conan2/p/coin-68aeb962954a5/p/lib/libOsiClp.so.1: undefined reference to `OsiSolverInterface::activateRowCutDebugger(char const*)'
collect2: error: ld returned 1 exit status
[161/228] Building CXX object software/SfM/clustering/domSetLibrary/CMakeFiles/domset.dir/domset.cc.o
ninja: build stopped: subcommand failed.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Apr 2, 2023

I suspect the same issue in conan-io/conan-center-index#16208 (comment)

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Apr 5, 2023

I see a similar issue in a recipe not merged yet in conan center.

On Linux with this profile:

[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
build_type=Release

You have to ckeckout first conan-io/conan-center-index#16355 and call conan create --version 1.9.2 -o "*:shared=True" -tf "" -b missing Then checkout conan-io/conan-center-index#16356 and call conan create . --version 2.0 -o "*:shared=True" -tf "" -b missing

You should see these errors (since it's related to link errors to coin-osi, you have less chance to inaverdently not reproduce the issue):

log

And indeed build of OpenMVG executables fails in c3i for "Linux all shared" because transitive shared libs don't seem to be added to -rpath-link: https://c3i.jfrog.io/c3i/misc-v2/logs/pr/16356/13-linux-gcc/openmvg/2.0//420b80fc6515bf813bb6636821a1a154a4010d07-build.txt

The common logic I see in these libraries is that:

  • they depend on an external foo library (let's call its CMake imported target foo::foo) provided by conan which itself has private external dependencies.
  • an internal library target libA links privately to imported target foo::foo with target_link_libraries(libA PRIVATE foo::foo). It works fine.
  • then an executable execA links to libA with target_link_libraries(execA PRIVATE libA). For some reason, CMake doesn't generate linker commands with -rpath-link to private dependencies of foo, therefore in libfoo.so linker can't find external symbols.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Apr 14, 2023

Same issue in test package of opencv: conan-io/conan-center-index#16678 (comment)

@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 10, 2023

@memsharded any chance that conan can track this issue? We have several repro cases in conan-center: opencv & openmvg. opencv recipe has an ugly workaround (protobuf libs are marked transitive, while they should not be).

@memsharded
Copy link
Member

I'd need some updated repro case, please, it seems the linked ones are already closed or outdated.

Also, investigating these things over ConanCenter recipes takes a lot more of time, that we usually don't have. Is not that we don't want to track it, is simply that we don't have more hours in the day, so they fall through the cracks. The chance to be able to address issues that are reported with simple conan new cmake_lib templates is a couple of orders of magnitude higher.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 10, 2023

You can't reproduce with conan new cmake_lib. It's a more complex case involving transitive dependencies, components, maybe specific usage of symbols in libs etc
I'll try to create a minimal repro case, but it's not trivial. OpenCV issue is reproducible if you take current recipe, remove transivite_libs=True in self.requires(protobuf) and run test package on Linux when all libs are shared.
I think it's related to #13010 (comment), which points out that current conan implementation is fragile.

SpaceIm added a commit to SpaceIm/conan_issue_13560 that referenced this issue May 10, 2023
@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 10, 2023

@memsharded Here is a minimal reproducible example: https://github.com/SpaceIm/conan_issue_13560. Instructions in README (3 conan create to run).

@memsharded memsharded added this to the 2.0.5 milestone May 10, 2023
@memsharded
Copy link
Member

memsharded commented May 10, 2023

Thanks for putting the repro case together.

I have checked it, and it seems this would work changing this:

--- a/libC_issue13560/CMakeLists.txt
+++ b/libC_issue13560/CMakeLists.txt
@@ -4,7 +4,7 @@ project(libC_issue13560 LANGUAGES CXX)
 find_package(libb_issue13560 REQUIRED CONFIG)

 add_library(libC_issue13560 libC_issue13560.cpp)
-target_link_libraries(libC_issue13560 PRIVATE libb_issue13560::libb_issue13560)
+target_link_libraries(libC_issue13560 PUBLIC libb_issue13560::libb_issue13560)

 add_executable(execC_issue_13560 execC_issue13560.cpp)
 target_link_libraries(execC_issue_13560 PRIVATE libC_issue13560

It is not expected that you can link the executable with the dependencies correctly if you make libC->libB PRIVATE.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 10, 2023

I've pushed a new commit (SpaceIm/conan_issue_13560@c43456f) which add an option in order to package flavors of libs with state of the art CMake config files, cmake_find_mode set to "none", and cpp_info.builddirs set to folder of CMake config file. It works fine in this case, so there is something wrong in CMakeDeps.

[ 25%] Building CXX object CMakeFiles/libC_issue13560.dir/libC_issue13560.cpp.o
/usr/bin/g++-12 -DlibC_issue13560_EXPORTS -isystem /home/spaceim/.conan2/p/libb_27335799c51cc/p/include -m64 -O3 -DNDEBUG -std=c++20 -fPIC -MD -MT CMakeFiles/libC_issue13560.dir/libC_issue13560.cpp.o -MF CMakeFiles/libC_issue13560.dir/libC_issue13560.cpp.o.d -o CMakeFiles/libC_issue13560.dir/libC_issue13560.cpp.o -c /home/spaceim/.conan2/p/t/libc_147870e29a469/b/libC_issue13560.cpp
[ 50%] Linking CXX shared library liblibC_issue13560.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/libC_issue13560.dir/link.txt --verbose=1
/usr/bin/g++-12 -fPIC -m64 -O3 -DNDEBUG -m64 -shared -Wl,-soname,liblibC_issue13560.so -o liblibC_issue13560.so CMakeFiles/libC_issue13560.dir/libC_issue13560.cpp.o  -Wl,-rpath,/home/spaceim/.conan2/p/libb_27335799c51cc/p/lib:/home/spaceim/.conan2/p/liba_4dd8731d25a2d/p/lib: /home/spaceim/.conan2/p/libb_27335799c51cc/p/lib/liblibB_issue13560.so -Wl,-rpath-link,/home/spaceim/.conan2/p/liba_4dd8731d25a2d/p/lib
gmake[2]: Leaving directory '/home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release'
[ 50%] Built target libC_issue13560
/usr/bin/gmake  -f CMakeFiles/execC_issue_13560.dir/build.make CMakeFiles/execC_issue_13560.dir/depend
gmake[2]: Entering directory '/home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release'
cd /home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/spaceim/.conan2/p/t/libc_147870e29a469/b /home/spaceim/.conan2/p/t/libc_147870e29a469/b /home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release /home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release /home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release/CMakeFiles/execC_issue_13560.dir/DependInfo.cmake --color=
gmake[2]: Leaving directory '/home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release'
/usr/bin/gmake  -f CMakeFiles/execC_issue_13560.dir/build.make CMakeFiles/execC_issue_13560.dir/build
gmake[2]: Entering directory '/home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release'
[ 75%] Building CXX object CMakeFiles/execC_issue_13560.dir/execC_issue13560.cpp.o
/usr/bin/g++-12   -m64 -O3 -DNDEBUG -std=c++20 -MD -MT CMakeFiles/execC_issue_13560.dir/execC_issue13560.cpp.o -MF CMakeFiles/execC_issue_13560.dir/execC_issue13560.cpp.o.d -o CMakeFiles/execC_issue_13560.dir/execC_issue13560.cpp.o -c /home/spaceim/.conan2/p/t/libc_147870e29a469/b/execC_issue13560.cpp
[100%] Linking CXX executable execC_issue_13560
/usr/bin/cmake -E cmake_link_script CMakeFiles/execC_issue_13560.dir/link.txt --verbose=1
/usr/bin/g++-12 -m64 -O3 -DNDEBUG -m64 CMakeFiles/execC_issue_13560.dir/execC_issue13560.cpp.o -o execC_issue_13560  -Wl,-rpath,/home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release:/home/spaceim/.conan2/p/libb_27335799c51cc/p/lib:/home/spaceim/.conan2/p/liba_4dd8731d25a2d/p/lib: liblibC_issue13560.so -Wl,-rpath-link,/home/spaceim/.conan2/p/libb_27335799c51cc/p/lib:/home/spaceim/.conan2/p/liba_4dd8731d25a2d/p/lib
gmake[2]: Leaving directory '/home/spaceim/.conan2/p/t/libc_147870e29a469/b/build/Release'
[100%] Built target execC_issue_13560

Here is the relevant content which might differ from files generated by CMakeDeps. Specifically the IMPORTED_LINK_DEPENDENT_LIBRARIES_* is missing in conan source code... (see https://cmake.org/cmake/help/latest/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES.html):

libA_issue13560Targets-release.cmake

#----------------------------------------------------------------
# Generated CMake target import file for configuration "Release".
#----------------------------------------------------------------

# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)

# Import target "libA_issue13560::libA_issue13560" for configuration "Release"
set_property(TARGET libA_issue13560::libA_issue13560 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(libA_issue13560::libA_issue13560 PROPERTIES
  IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/liblibA_issue13560.so"
  IMPORTED_SONAME_RELEASE "liblibA_issue13560.so"
  )

list(APPEND _cmake_import_check_targets libA_issue13560::libA_issue13560 )
list(APPEND _cmake_import_check_files_for_libA_issue13560::libA_issue13560 "${_IMPORT_PREFIX}/lib/liblibA_issue13560.so" )

# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)

libB_issue13560Targets-release.cmake

#----------------------------------------------------------------
# Generated CMake target import file for configuration "Release".
#----------------------------------------------------------------

# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)

# Import target "libB_issue13560::libB_issue13560" for configuration "Release"
set_property(TARGET libB_issue13560::libB_issue13560 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(libB_issue13560::libB_issue13560 PROPERTIES
  IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE "libA_issue13560::libA_issue13560"
  IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/liblibB_issue13560.so"
  IMPORTED_SONAME_RELEASE "liblibB_issue13560.so"
  )

list(APPEND _cmake_import_check_targets libB_issue13560::libB_issue13560 )
list(APPEND _cmake_import_check_files_for_libB_issue13560::libB_issue13560 "${_IMPORT_PREFIX}/lib/liblibB_issue13560.so" )

# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)

@memsharded
Copy link
Member

It is a known issue that Conan doesn't have the full information to define IMPORTED things in CMakeDeps.
This will require some time to fix, probably some new features and a new optin for new CMakeDeps internal implementation.

As there is a relatively easy workaround defining the target_link_libraries(PUBLIC), moving this to 2.X, to be done when working on #13018

@memsharded memsharded modified the milestones: 2.0.5, 2.X May 11, 2023
@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 11, 2023

Ok, thanks.

As there is a relatively easy workaround defining the target_link_libraries(PUBLIC), moving this to 2.X, to be done when working on #13018

It's not an easy workaround when you have to patch CML forever. An easy workaround is to inject VirtualRunEnv into build scope.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 12, 2023

Here is a summary I made, hoping it can help to improve CMakeDeps:

CMake config file

Context

  • We have two libs: libA and libB, where libB may depend on libA. We are interesting to the content of state-of-the-art CMake config file of libB generated in install tree by install(EXPORT ...).

  • libB is a C++ library (it leads to IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" property when libB is STATIC, but except of that the result would be the same for a C library). It's worth noting that conan doesn't add this property, therefore several recipes propagate stdcpp_library() in system libs if shared=False as a workaround (this workaround can be a problem for folks who want to link to static C++ standard library).

  • libB has an interface definition FOO, and interface compile feature cxx_std_11 (doesn't really matter to model link between libA & libB, but it shows how it's translated in a CMake config file. Note that conan has no concept of interface compile feature. Interface definition would basically be cpp_info.defines in libb recipe)

Matrix

  • libA TYPE:

    • INTERFACE_LIBRARY
    • STATIC_LIBRARY
    • SHARED_LIBRARY
  • libB TYPE:

    • INTERFACE_LIBRARY
    • STATIC_LIBRARY
    • SHARED_LIBRARY
  • libA and libB relationship:

    • libB doesn't depend on libA
    • libB depends on libA:
      • if libB is INTERFACE TYPE, libA can't be anything else than an INTERFACE dependency of libB
      • otherwise:
        • libA is a PUBLIC dependency of libB
        • libA is a PRIVATE dependency of libB

Results

  1. INTERFACE libB

    1.1. No dependency

    # Config invariant
    add_library(libB::libB INTERFACE IMPORTED)
    set_target_properties(libB::libB PROPERTIES
        INTERFACE_COMPILE_DEFINITIONS "FOO"
        INTERFACE_COMPILE_FEATURES "cxx_std_11"
        INTERFACE_INCLUDE_DIRECTORIES "<path/to/libB/includedir>"
    )

    2.1. Depends on INTERFACE or STATIC or SHARED libA

    # Config invariant
    add_library(libB::libB INTERFACE IMPORTED)
    set_target_properties(libB::libB PROPERTIES
        INTERFACE_COMPILE_DEFINITIONS "FOO"
        INTERFACE_COMPILE_FEATURES "cxx_std_11"
        INTERFACE_INCLUDE_DIRECTORIES "<path/to/libB/includedir>"
        INTERFACE_LINK_LIBRARIES "libA::libA"
    )
  2. STATIC libB

    2.1. No dependency

    # Config invariant
    add_library(libB::libB STATIC IMPORTED)
    set_target_properties(libB::libB PROPERTIES
        INTERFACE_COMPILE_DEFINITIONS "FOO"
        INTERFACE_COMPILE_FEATURES "cxx_std_11"
        INTERFACE_INCLUDE_DIRECTORIES "<path/to/libB/includedir>"
    )
    
    # Config specific
    set_property(TARGET libB::libB APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
    set_target_properties(libB::libB PROPERTIES
        IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
        IMPORTED_LOCATION_RELEASE "<path/to/libB/static_file>"
    )

    2.2. Depends on INTERFACE or STATIC or SHARED libA (PRIVATE)

    # Config invariant
    add_library(libB::libB STATIC IMPORTED)
    set_target_properties(libB::libB PROPERTIES
        INTERFACE_COMPILE_DEFINITIONS "FOO"
        INTERFACE_COMPILE_FEATURES "cxx_std_11"
        INTERFACE_INCLUDE_DIRECTORIES "<path/to/libB/includedir>"
        INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:libA::libA>"
    )
    
    # Config specific
    set_property(TARGET libB::libB APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
    set_target_properties(libB::libB PROPERTIES
        IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
        IMPORTED_LOCATION_RELEASE "<path/to/libB/static_file>"
    )

    2.3. Depends on INTERFACE or STATIC or SHARED libA (PUBLIC)

    # Config invariant
    add_library(libB::libB STATIC IMPORTED)
    set_target_properties(libB::libB PROPERTIES
        INTERFACE_COMPILE_DEFINITIONS "FOO"
        INTERFACE_COMPILE_FEATURES "cxx_std_11"
        INTERFACE_INCLUDE_DIRECTORIES "<path/to/libB/includedir>"
        INTERFACE_LINK_LIBRARIES "libA::libA"
    )
    
    # Config specific
    set_property(TARGET libB::libB APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
    set_target_properties(libB::libB PROPERTIES
        IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
        IMPORTED_LOCATION_RELEASE "<path/to/libB/static_file>"
    )
  3. SHARED libB

    3.1. No dependency or depends on INTERFACE or STATIC libA (PRIVATE)

    # Config invariant
    add_library(libB::libB SHARED IMPORTED)
    set_target_properties(libB::libB PROPERTIES
        INTERFACE_COMPILE_DEFINITIONS "FOO"
        INTERFACE_COMPILE_FEATURES "cxx_std_11"
        INTERFACE_INCLUDE_DIRECTORIES "<path/to/libB/includedir>"
    )
    
    # Config specific
    set_property(TARGET libB::libB APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
    set_target_properties(libB::libB PROPERTIES
        IMPORTED_LOCATION_RELEASE "<path/to/libB/dll_or_so_or_dylib>"
        # if Windows
        IMPORTED_IMPLIB_RELEASE "<path/to/libB/import_lib_of_dll>"
        # if not Windows
        IMPORTED_SONAME_RELEASE "<@rpath/libB.dylib if Apple else libB.so>"
    )

    3.2. Depends on SHARED libA (PRIVATE)

    # Config invariant
    add_library(libB::libB SHARED IMPORTED)
    set_target_properties(libB::libB PROPERTIES
        INTERFACE_COMPILE_DEFINITIONS "FOO"
        INTERFACE_COMPILE_FEATURES "cxx_std_11"
        INTERFACE_INCLUDE_DIRECTORIES "<path/to/libB/includedir>"
    )
    
    # Config specific
    set_property(TARGET libB::libB APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
    set_target_properties(libB::libB PROPERTIES
        IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE "libA::libA"
        IMPORTED_LOCATION_RELEASE "<path/to/libB/dll_or_so_or_dylib>"
        # if Windows
        IMPORTED_IMPLIB_RELEASE "<path/to/libB/import_lib_of_dll>"
        # if not Windows
        IMPORTED_SONAME_RELEASE "<@rpath/libB.dylib if Apple else libB.so>"
    )

    3.3. Depends on INTERFACE or STATIC or SHARED libA (PUBLIC)

    # Config invariant
    add_library(libB::libB SHARED IMPORTED)
    set_target_properties(libB::libB PROPERTIES
        INTERFACE_COMPILE_DEFINITIONS "FOO"
        INTERFACE_COMPILE_FEATURES "cxx_std_11"
        INTERFACE_INCLUDE_DIRECTORIES "<path/to/libB/includedir>"
        INTERFACE_LINK_LIBRARIES "libA::libA"
    )
    
    # Config specific
    set_property(TARGET libB::libB APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
    set_target_properties(libB::libB PROPERTIES
        IMPORTED_LOCATION_RELEASE "<path/to/libB/dll_or_so_or_dylib>"
        # if Windows
        IMPORTED_IMPLIB_RELEASE "<path/to/libB/import_lib_of_dll>"
        # if not Windows
        IMPORTED_SONAME_RELEASE "<@rpath/libB.dylib if Apple else libB.so>"
    )

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Nov 13, 2023

@memsharded It may be a coincidence, but another similarity is that dependencies which seem to trigger this issue in some recipes depending on them, have cmake_find_mode set to both (freetype, libtiff, protobuf).

SpaceIm added a commit to SpaceIm/conan-center-index that referenced this issue Nov 14, 2023
conan-center-bot pushed a commit to conan-io/conan-center-index that referenced this issue May 28, 2024
* add package_type

* bump freetype & libpng

* avoid patch in 1.10

* add msdfgen/1.11

* inject BUILD_SHARED_LIBS as cache_variables

* simplify patching strategy of previous versions

* restore find_package module freetype

* remove pdb files

* Revert "restore find_package module freetype"

This reverts commit d678393.

* workaround for conan-io/conan#13560

* bump freetype

* less verbose package_info()

* Update recipes/msdfgen/all/conanfile.py

Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com>

---------

Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com>
@jcar87
Copy link
Contributor

jcar87 commented Dec 9, 2024

I can confirm that the newer/still experimental CMakeDeps fixes this issue and we've managed to isolate and reproduce it.

Based on the original issue reported in the issue description:

Still, openssl crypto is missing in -rpath-link when linker tries to create libzippp shared lib.

This is a bit nuanced, the linker is not failing to a create the libzippp shared lib - the linker is failing to link the libzippp_shared_test executable within the libzippp project when creating the shared variant of the package.

This is due to this:
https://github.com/ctabin/libzippp/blob/a570af1e3b11292567c9542d4f60bb3b15f037b3/CMakeLists.txt#L84-L92

At this point, the libzippp library target, is not a target created by CMakeDeps, so it doesn't benefit from the earlier fix in #13010

Other instances of CMake not adding -rpath/-rpath-link when the target was generated by Conan... are actually different bugs altogether. But at least the one originally reported in this issue, I believe the newer CMakeDeps implementation fixes it. This is not a widespread issue in COnan Center because not all libraries build executables (as we typically disable tests, docs, etc).

The issue only happens when using the GNU bfd Linker (the default on most Linuxes) - if gold, lld or mold are used, this is unlikely to be a problem

Possible workarounds for "older" CMakeDeps:

  • Just have an rpath pointing to all host library directories - this should have little effect of negative consequences (the build rpath should not end up in the packaged library anyway)
        if self.settings.os == "Linux":
            libdirs_host = [l for dependency in self.dependencies.host.values() for l in dependency.cpp_info.aggregated_components().libdirs]
            tc.variables["CMAKE_BUILD_RPATH"] = ";".join(libdirs_host)
tools.build:exelinkflags=['-fuse-ld=bfd', '-Wl,--allow-shlib-undefined']

EIther way this should be preferred over tweaking any build scripts to use a public instead of private dependency.

The underlying cause is indeed a lack of the IMPORTED_LINK_DEPENDENT_LIBRARIES_ - we're looking into implementing that in the new CMakeDeps, which should also take care of the issue when crossbuilding with a sysroot (in which case there should be -rpath-link instead of -rpath)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants