[bug] system_libs are linked before objects causing undefined references
See original GitHub issueI 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:
- Created a year ago
- Comments:7 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
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()