bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Android environments
@ 2022-12-27  7:04 Bruno Haible
  2022-12-27  8:04 ` Po Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2022-12-27  7:04 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Po Lu

Po Lu wrote:
> The compilation is done on the host machine that's building Emacs (to
> produce emacs.so), which is then copied to the lib directory in the APK
> package.

I see. There are two ways to build C programs for Android:

  (A) The way it is designed by Google: With the Android NDK,
      that includes a cross-compiler. For the runtime, use an emulator
      (based on qemu) or a physical connection to a real device.

  (B) Inside a terminal emulator app (Termux [1][2] for Android ≥ 7,
      Terminal-IDE [3] for Android < 5).

(A) is a POSIX-like environment only at the C level; it has no shell and no
utilities.

(B) is a POSIX-like environment including shell and utilities.

For building a real app, the approach (A) is what one needs.

But for building and testing a library, the approach (B) provides
  - an environment that allows to reuse build infrastructure (configure etc.)
    from GNU,
  - faster turnaround cycles.

For Gnulib, we have only used approach (B). We *hope* that the resulting
source code will also work well in situation (A). But when you hit a problem
in situation (A), you are on your own. Because I won't install an NDK and
get into the complexities of cross-compilation, APK packaging, and so on.

> > Again, what is the Android API level that you are using?
> 19.

This is supported with Gnulib, as I have done a lot of testing with Android 4.3
(API level 18).

Bruno

[1] https://f-droid.org/en/packages/com.termux/
[2] https://wiki.termux.com/wiki/Main_Page
[3] https://www.spartacusrex.com/terminalide.htm





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Android environments
  2022-12-27  7:04 Android environments Bruno Haible
@ 2022-12-27  8:04 ` Po Lu
  2022-12-27 13:56   ` Jeffrey Walton
  0 siblings, 1 reply; 3+ messages in thread
From: Po Lu @ 2022-12-27  8:04 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

Bruno Haible <bruno@clisp.org> writes:

> I see. There are two ways to build C programs for Android:
>
>   (A) The way it is designed by Google: With the Android NDK,
>       that includes a cross-compiler. For the runtime, use an emulator
>       (based on qemu) or a physical connection to a real device.
>
>   (B) Inside a terminal emulator app (Termux [1][2] for Android ≥ 7,
>       Terminal-IDE [3] for Android < 5).
>
> (A) is a POSIX-like environment only at the C level; it has no shell and no
> utilities.
>
> (B) is a POSIX-like environment including shell and utilities.
>
> For building a real app, the approach (A) is what one needs.
>
> But for building and testing a library, the approach (B) provides
>   - an environment that allows to reuse build infrastructure (configure etc.)
>     from GNU,
>   - faster turnaround cycles.
>
> For Gnulib, we have only used approach (B). We *hope* that the resulting
> source code will also work well in situation (A). But when you hit a problem
> in situation (A), you are on your own. Because I won't install an NDK and
> get into the complexities of cross-compilation, APK packaging, and so on.
>
>> > Again, what is the Android API level that you are using?
>> 19.
>
> This is supported with Gnulib, as I have done a lot of testing with Android 4.3
> (API level 18).

Thanks for explaining the situation.  Emacs will definitely be a
category "A" program, so I hope it will help improve gnulib's support
for those environments.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Android environments
  2022-12-27  8:04 ` Po Lu
@ 2022-12-27 13:56   ` Jeffrey Walton
  0 siblings, 0 replies; 3+ messages in thread
From: Jeffrey Walton @ 2022-12-27 13:56 UTC (permalink / raw)
  To: Po Lu; +Cc: Bruno Haible, bug-gnulib

On Tue, Dec 27, 2022 at 3:05 AM Po Lu <luangruo@yahoo.com> wrote:
>
> Bruno Haible <bruno@clisp.org> writes:
>
> > I see. There are two ways to build C programs for Android:
> >
> >   (A) The way it is designed by Google: With the Android NDK,
> >       that includes a cross-compiler. For the runtime, use an emulator
> >       (based on qemu) or a physical connection to a real device.
> >
> >   (B) Inside a terminal emulator app (Termux [1][2] for Android ≥ 7,
> >       Terminal-IDE [3] for Android < 5).
> >
> > (A) is a POSIX-like environment only at the C level; it has no shell and no
> > utilities.
> >
> > (B) is a POSIX-like environment including shell and utilities.
> >
> > For building a real app, the approach (A) is what one needs.
> >
> > But for building and testing a library, the approach (B) provides
> >   - an environment that allows to reuse build infrastructure (configure etc.)
> >     from GNU,
> >   - faster turnaround cycles.
> >
> > For Gnulib, we have only used approach (B). We *hope* that the resulting
> > source code will also work well in situation (A). But when you hit a problem
> > in situation (A), you are on your own. Because I won't install an NDK and
> > get into the complexities of cross-compilation, APK packaging, and so on.
> >
> >> > Again, what is the Android API level that you are using?
> >> 19.
> >
> > This is supported with Gnulib, as I have done a lot of testing with Android 4.3
> > (API level 18).
>
> Thanks for explaining the situation.  Emacs will definitely be a
> category "A" program, so I hope it will help improve gnulib's support
> for those environments.

Also see https://developer.android.com/ndk/guides/other_build_systems .

I've found that if a project honors a user's flags (like CC, CXX,
CPPFLAGS, CFLAGS, CXXFLAGS and LDFLAGS), then it will cross-compile
just fine under Android. The rub is, the user has to set the
environment properly and set sysroot properly in *FLAGS.

The tricky thing about Android is, the devs change things every few
iterations and it breaks something. So something that worked under r16
is broken at r19, something that worked under r19 is broken at r21,
etc. The latest seems to be the names of the binaries used for AR and
RANLIB. In the past they were named like aarch64-linux-android-ar and
aarch64-linux-android-ranlib. Today they are named llvm-ar and
llvm-ranlib.

Jeff


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-27 13:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-27  7:04 Android environments Bruno Haible
2022-12-27  8:04 ` Po Lu
2022-12-27 13:56   ` Jeffrey Walton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).