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 lib (dl) ordering change on link

See original GitHub issue

Environment Details (include every applicable attribute)

  • Operating System+version: Debian bullseye
  • Compiler+version: gcc 11
  • Conan version: 1.51
  • Python version: 3.9.2

Steps to reproduce (Include if Applicable)

Not easy, but lot of dependencies and openssl with dl usage (using crypto)

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

/usr/bin/c++  -pipe -Wall -fstack-protector-all -fstack-check -O3 -DNDEBUG  -Wl,-z,relro -Wl,--as-needed CMakeFiles/bin_beauty_application_singleton.dir/beauty_application_singleton.cpp.o -o ../../../bin/beauty_application_singleton  ../../../lib/libbeauty.a /home/dfleury/.conan/data/openssl/1.1.1q/_/_/package/fae585d7c68637b721c0c4c0d1c52174d067eda8/lib/libssl.a -ldl /home/dfleury/.conan/data/openssl/1.1.1q/_/_/package/fae585d7c68637b721c0c4c0d1c52174d067eda8/lib/libcrypto.a -lrt -lpthread -lstdc++fs 

Here -ldl is placed before crypto.a, so I get

usr/bin/ld: /home/dfleury/.conan/data/openssl/1.1.1q/_/_/package/fae585d7c68637b721c0c4c0d1c52174d067eda8/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x13): undefined reference to `dlopen'

If I use conan 1.49 or conan 1.50, it works fine.

usr/bin/c++  -pipe -Wall -fstack-protector-all -fstack-check -O3 -DNDEBUG  -Wl,-z,relro -Wl,--as-needed CMakeFiles/bin_beauty_chat.dir/beauty_chat.cpp.o -o ../../../bin/beauty_chat  ../../../lib/libbeauty.a /home/dfleury/.conan/data/openssl/1.1.1q/_/_/package/fae585d7c68637b721c0c4c0d1c52174d067eda8/lib/libssl.a /home/dfleury/.conan/data/openssl/1.1.1q/_/_/package/fae585d7c68637b721c0c4c0d1c52174d067eda8/lib/libcrypto.a /home/dfleury/.conan/data/openssl/1.1.1q/_/_/package/fae585d7c68637b721c0c4c0d1c52174d067eda8/lib/libcrypto.a -ldl -lpthread -lrt -lstdc++fs 

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dfleury2commented, Aug 4, 2022

I am using some “scripts” to generate lot of boring stuff. Hard to extract it easily. But something as simple as:

find_package(Boost CONFIG REQUIRED)
find_package(OpenSSL CONFIG REQUIRED)

add_library(mylib ...)
target_link_library(mylib PUBLIC Boost::headers opensssl::openssl)

add_executable(myexe ...)
target_link_library(myexe PUBLIC mylib::mylib)

just that I generated a variable inside conanfile.py that list all dependencies generated (*.cmake files), pass it to CMake, to call each find_package.

and I have a macro to replace add_library/target_link_libraries in a single call.

1reaction
dfleury2commented, Aug 4, 2022

Ok, I found something that work, on a direct dependency. Currently I am using openssl::opensslas dependency (but broken). If I use

OpenSSL::crypto
OpenSSL::SSL

in this exact order it works fine. If I put SSL before crypto, it’s broken again, the dl lib is after ssl.a but before crypto.a Hope this one help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DL Ordering - Trident Connect
We appreciate your understanding as we consolidate online ordering systems into a single, convenient portal. We anticipate this process to be completed in ......
Read more >
Dynamic link library (DLL) - Windows Client | Microsoft Learn
This article describes what a dynamic link library (DLL) is and the various issues that may occur when you use DLLs.
Read more >
What is dynamic link library (DLL)? - TechTarget
A dynamic link library (DLL) is a collection of small programs that larger programs can load when needed to complete specific tasks.
Read more >
Why does the order in which libraries are linked sometimes ...
Linking to static libraries ... The linker searches from left to right, and notes unresolved symbols as it goes. If a library resolves...
Read more >
Google Play Billing Library release notes - Android Developers
Google Play's billing system ... These replace Purchase#getSku and PurchaseHistoryRecord#getSku which have been removed. ... Java and Kotlin Bug fixes.
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