finagolfin/swift-android-sdk

Where is “libz.so.1” supposed to be?

SDGGiesbrecht opened this issue · 6 comments

I am experimenting with switching to your SDKs (they look cleaner than the ones I have been building), but I am getting “library "libz.so.1" not found” when I launch an .xctest executable. Where is that library supposed to be in the first place?

A full action script and corresponding log have additional details if you need them.

I checked my SDK libraries and I only see two libraries that link libz.so.1: libcurl.so and libxml2.so. That likely means you are using FoundationXML or FoundationNetworking, both of which I provide but do not support running:

The libcurl and libxml2 packages are only needed for the FoundationNetworking and FoundationXML libraries respectively, so you don't have to deploy them on the Android device if you don't use those extra Foundation libraries.

I simply include all four libraries since there's currently no way to disable building them in the CMake configuration, but they won't actually run on Android with this SDK, as libcurl and libxml2 have other library dependencies that aren't included. If you want to use either of these separate Foundation libraries, you will have to track down those other libcurl/xml2 dependencies and include them yourself.

Okay, that makes sense.

I already have a build of zlib that I used for building previous releases of Swift. Do you think the SDK is built such that dropping it into the SDK right beside libcurl ought to work? Or do you think that might fail because it wasn’t there when Foundation was compiled?

I will probably get around to trying it on Monday.

(I already tried it with the zlib from the NDK, but that just resulted in other missing dependencies I had never heard of.)

If I were you, I'd simply disable the only test where you're using these two libraries for Android too.

If you really want to use them, you will have to supply all the dependencies of those libraries, and the dependencies of those dependencies, and so on. You could check their dependencies in their termux build scripts, then download each of those prebuilt binary packages for Termux in turn, as my script that builds the SDK does.

Do you think the SDK is built such that dropping it into the SDK right beside libcurl ought to work? Or do you think that might fail because it wasn’t there when Foundation was compiled?

Yes, that will work because I set the RPATH to $ORIGIN for those libraries, and you will want to set the RPATH for any other libraries you add, so they can find their dependencies too.

Good luck, you will need it. 😄

zlib seems to work fine either by loading it from the system or copying it out of the 5.4 SDK whose build script I inherited from Saleem.

The ones pulling in all the weird dependencies are libcurl and libxml2, which seems odd, because Saleem’s SDK did not even include .sos for either of them, yet all three components of Foundation worked. I hunted through the script and discovered they were linked statically into Foundation and never included separately in Saleem’s SDK. They also don’t need any transitive dependencies when built that way (at least that aren’t found automatically). I feel like there might be something wrong in the official build script.

I don't know what static linking config of libcurl/xml2 you're referring to, as I have never looked at Saleem's builds and I don't think that's in the swift-corelibs-foundation repo's CMake config, which the official build script simply calls. It's possible that approach is much easier but since I have no interest in using those libraries, I haven't looked into it.

Fixing it is probably above my ability, but his scripts are now two years stale. I think I will check the downstream projects and see about just dropping support for FoundationNetworking and FoundationXML in order to switch over to your SDKs anyway.