Android: link libdl into rnp's OpenSSL feature probe - #376
Open
jolavillette wants to merge 1 commit into
Open
Conversation
rnp builds a findopensslfeatures helper and runs it to enumerate the
OpenSSL features. When cross-compiling it links that helper statically so
it does not need the Android dynamic linker, but OpenSSL 1.1.1
libcrypto.a pulls in dso_dlfcn.o, which references the dl* API, and
CMake's FindOpenSSL does not add ${CMAKE_DL_LIBS} to the OpenSSL::Crypto
interface here. Nothing provides those symbols and build_librnp dies at
ld.lld: error: undefined symbol: dlopen
>>> referenced by dso_dlfcn.c
>>> dso_dlfcn.o:(dlfcn_load) in archive
>>> .../sysroot/usr/lib/libcrypto.a
CMake Error at cmake/Modules/FindOpenSSLFeatures.cmake:149 (message):
Error building findopensslfeatures
The NDK ships a static libdl.a defining dlopen/dlsym/dlclose/dlerror, so
link it explicitly. It is added as a linked library, not through
CMAKE_EXE_LINKER_FLAGS, because it must appear after libcrypto.a on the
link line for the static linker to resolve from it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
build_librnpfails while rnp configures itself:rnp compiles a small
findopensslfeatureshelper and runs it to enumerate theOpenSSL features. When cross-compiling it links that helper statically, so it
does not need the Android dynamic linker:
but OpenSSL 1.1.1's
libcrypto.apulls indso_dlfcn.o, which references thedl*API, and CMake'sFindOpenSSLdoes not add${CMAKE_DL_LIBS}to theOpenSSL::Cryptointerface here. The link line ends up aswith nothing providing
dlopen,dlsym,dlcloseanddlerror.The NDK does ship a static
libdl.adefining those four for real, so it isenough to link it. It is added as a linked library rather than through
CMAKE_EXE_LINKER_FLAGS, because CMake places that variable before theobjects, where a static linker has no undefined symbol to resolve yet and drops
the archive silently.
This is arguably rnp's bug — their
-staticpath looks untested against astatic OpenSSL 1.1.1 — so the patch stays a
sednext to the existing ones, andshould be dropped once rnp handles it.
Verified
build_librnpcompletes and installslibrnp.ain the sysroot, and the wholeAAR now builds: 42 MB,
jni/arm64-v8a/libretroshare.soexportingJNI_OnLoad,the four
org.retroshare.serviceclasses inclasses.jar. Ubuntu 24.04, NDK29.0.14206865, API level 24,arm64-v8a, on top of #373 and #375.