question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] transient linkage with pure cmake_find_package

See original GitHub issue

As seen in this slack: https://cpplang.slack.com/archives/C41CWV9HA/p1631005375278900

According to the docs it is recommended to ... not need to specify or include anything related with Conan at all; just rely on the find_package feature .... This seems to be not true, as it seems that conan_basic_setup() is still somehow required to get 100% of conans functionality, especially if multiple, chained shared libraries are involved (I guess the LD_LIBRARY_PATH is missing).

Environment Details (include every applicable attribute)

  • Operating System+version: Ubuntu 18.04
  • Compiler+version: gcc7
  • Conan version: 1.40+
  • Python version: 3.6.9

Steps to reproduce (Include if Applicable)

clone https://github.com/blackliner/conan_transient_linkage run build.sh

@ericLemanissier 's PR fixes it, while loosing CMake purity: https://github.com/blackliner/conan_transient_linkage/pull/1

Logs (Executed commands with output) (Include/Attach if Applicable)

...
[ 75%] Building CXX object tests/CMakeFiles/lib_a_test.dir/lib_a_test.cpp.o
[100%] Linking CXX executable lib_a_test
/usr/bin/ld: warning: liblib_c.so, needed by //home/fberchtold/.conan/data/lib_b/1.0.0/_/_/package/436fa0a6d3ec3ce29639456d6db8d06cd9bf62c9/lib/liblib_b.so, not found (try using -rpath or -rpath-link)
//home/fberchtold/.conan/data/lib_b/1.0.0/_/_/package/436fa0a6d3ec3ce29639456d6db8d06cd9bf62c9/lib/liblib_b.so: undefined reference to `lum::lib_c::SayHello[abi:cxx11]()'
collect2: error: ld returned 1 exit status
tests/CMakeFiles/lib_a_test.dir/build.make:98: recipe for target 'tests/lib_a_test' failed
make[2]: *** [tests/lib_a_test] Error 1
CMakeFiles/Makefile2:881: recipe for target 'tests/CMakeFiles/lib_a_test.dir/all' failed
make[1]: *** [tests/CMakeFiles/lib_a_test.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2
lib_a/1.0.0: 
lib_a/1.0.0: ERROR: Package '4c3f20be28cf1be70e428d9fc0e689236ff00f59' build failed
lib_a/1.0.0: WARN: Build folder /home/fberchtold/.conan/data/lib_a/1.0.0/_/_/build/4c3f20be28cf1be70e428d9fc0e689236ff00f59
ERROR: lib_a/1.0.0: Error in build() method, line 52
        cmake.build()
        ConanException: Error 2 while executing cmake --build '/home/fberchtold/.conan/data/lib_a/1.0.0/_/_/build/4c3f20be28cf1be70e428d9fc0e689236ff00f59' '--' '-j24'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
blacklinercommented, Sep 13, 2021

Nice, thanks, I think thats it for today 😃

1reaction
memshardedcommented, Sep 13, 2021

See the error log in the OP, shared objects of transient deps cannot be found during linking.

There are linkers that will skip a library if it doesn’t match its expected architecture, looking like it didn’t found a library that is there, you can find in the filesystem, but it keeps telling you library not found. I have verified this a couple of times, cannot be sure if it is the current issue, but worth at least considering.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CMake FIND_PACKAGE succeeds but returns wrong path
This problem occurs when using some older versions of boost with cmake-2.8.6-rc2 or later, where the boost package finding code was changed.
Read more >
find_package — CMake 3.25.1 Documentation
The REQUIRED option stops processing with an error message if the package ... In pure Config mode, the command skips Module mode search...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found