Subject: Re: Build versionless .so for Android

From: Peter Eisentraut <[email-masked]>
Date: Thu, 18 Jan 2024 09:27:55 +0100

On 14.01.24 12:37, Matthias Kuhn wrote:
> What I try to do is packaging an app with androiddeployqt which fails 
> with an error:
> 
> The bundled library lib/libpq.so.5 doesn't end with .so. Android only 
> supports versionless libraries ending with the .so suffix.
> 
> This error was introduced in response to this issue which contains hints 
> about the underlying problem:
> 
> https://bugreports.qt.io/plugins/servlet/mobile#issue/QTBUG-101346 
> <https://bugreports.qt.io/plugins/servlet/mobile#issue/QTBUG-101346>

I think the scenario there is using dlopen(), possibly via Qt, possibly 
via Java, so it's a very specific scenario, not necessarily indicative 
of a general requirement on Android, and apparently not using build-time 
linking.  It's quite conceivable that this issue would also exist with 
Qt on other platforms.

As I mentioned before, Meson has Android support.  Some people there 
clearly thought about it.  So I suggest you try building PostgreSQL for 
your Android environment using Meson and see what it produces.(*)  If 
the output files are the same as the autoconf/make build, then I would 
think your scenario is nonstandard.  If the output files are different, 
then we should check that and consider changes to get them to match.

It's of course possible that Meson is wrong, too, but then we need to 
have a broader analysis, because the implicit goal is to keep the two 
build systems for PostgreSQL consistent.

(*) - This means specifically that the installation trees produced by 
"make install-world-bin" and "meson install" should produce exactly the 
same set of files (same names in the same directories, not necessarily 
the same contents).

---

From: Matthias Kuhn <[email-masked]>
Date: Fri, 19 Jan 2024 11:08:59 +0100

Hi

> linking.  It's quite conceivable that this issue would also exist with
I haven't experienced this issue with Qt on any other platform (and I build
and run the same stack on windows, linux, macos and ios).
Also the links posted earlier in this thread hint to the same limitation of
Android, unrelated to Qt.

> build systems for PostgreSQL consistent.

When trying to build with meson, including the patch which was provided by
Andres Freud (thanks),
I am currently stuck with the following error:

Configuring pg_config_ext.h using configuration

../src/tgresql-16-685bc9fc97.clean/src/include/meson.build:12:0: ERROR:
File port/android.h does not exist.

Kind regards
Matthias

---

From: Peter Eisentraut <[email-masked]>
Date: Fri, 19 Jan 2024 15:00:40 +0100

On 19.01.24 11:08, Matthias Kuhn wrote:
> When trying to build with meson, including the patch which was provided 
> by Andres Freud (thanks),

I think there is actually small bug in the meson setup.

In the top-level meson.build, line 166 has

     portname = host_system

but then later around line 190, host_system is changed for some cases 
(including the android case that was added in the proposed patch).  So 
that won't work, and probably also won't work for the existing cases 
there.  The portname assignment needs to be moved later in the file. 
Maybe you can try that on your own.

---

From: Matthias Kuhn <[email-masked]>
Date: Fri, 19 Jan 2024 18:12:24 +0100

Thanks,

This patch brought it further and indeed, the resulting libpq.so file is
unversioned when built for Android while it's versioned when built for
linux.

Matthias

---

From: Peter Eisentraut <[email-masked]>
Date: Tue, 23 Jan 2024 20:42:54 +0100

> unversioned when built for Android while it's versioned when built for 

Ok, I have committed all of this now:

- Fix for correct order of host_system and portname assignment in 
meson.build.

- Patch from Andres to map android to linux in meson.build.

- Makefile.shlib support for Android (based on your patch, but I 
reworked it a bit).

So this should all work for you now.