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] system_libs are linked before objects causing undefined references

See original GitHub issue

I have a recipe which includes compiled objects which depend on system libraries so I produce the following package info

    def package_info(self):
        self.cpp_info.objects = [os.path.join("lib", o) for o in objects]
        self.cpp_info.system_libs = ["pthread", "dl"]

however, the CMake config files produced link the system libs before the objects, which, on some systems, makes the linker not find the required symbols:

(.text+0x191a89): undefined reference to `pthread_setaffinity_np'
(.text+0x191aba): undefined reference to `dlsym'

seems like the order should be reversed in https://github.com/conan-io/conan/blob/0eb405bde999d5b7b8e706b206940d2e24aa828e/conan/tools/cmake/cmakedeps/templates/target_configuration.py#L117-L120

Environment Details (include every applicable attribute)

  • Operating System+version: Ubuntu 18.04
  • Compiler+version: GCC 8
  • Conan version: 1.44.1

Steps to reproduce (Include if Applicable)

see above

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dvirtzcommented, May 31, 2022

Hi @dvirtz,

Thanks for the tips, Do you put this snippet in package_info method of conanfile.py of consumer? For example in my case, in conanfile.py of glog consumer?

no, I put it in the package_info of the package exporting those objects, so maybe this is not relevant if you don’t control the dependency

1reaction
memshardedcommented, May 31, 2022

We plan to branch 1.49 today if possible. I don’t think there is any reasonable workaround, beyond redefining targets variables directly in your consumer CMakeLists.txt after the find_package()

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is an undefined reference/unresolved external symbol ...
Before linking, it simply assumes that that symbol was defined somewhere, but it doesn't yet care where. The linking phase is responsible for...
Read more >
C++ Errors: Undefined Reference, Unresolved External ...
An “Undefined Reference” error occurs when we have a reference to object name (class, function, variable, etc.) in our program and the linker ......
Read more >
91664 – Undefined reference linker errors when static linking ...
Bug 91664 - Undefined reference linker errors when static linking archive with gcc target_clones function multi-versioning.
Read more >
Undefined Symbols (Linker and Libraries Guide)
These symbol references are referred to as undefined symbols. Undefined symbols can affect the link-edit process according to the type of symbol, ...
Read more >
GCC: Linker Error (undefined Reference with C++)
The GNU Linker gives error messages while linking an application, which contains class declarations and class instances. CAUSE. The class declaration specifies ...
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