Bug #3832

libosmocore no longer builds with Android NDK

Added by supersat 2 months ago. Updated 2 months ago.

Target version:
Start date:
Due date:
% Done:


Spec Reference:


When building libosmocore with the Android NDK, it fails complaining about this line (103) in src/gsm/gsm_utils.c:

#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,25)

This code doesn't work as intended -- if __GLIBC_PREREQ isn't defined, then the preprocessor will be unable to parse that expression.

I've attached a suggested fix which breaks up this check into multiple lines.

glibc_prereq.patch glibc_prereq.patch 1.25 KB supersat, 03/10/2019 10:23 PM


#1 Updated by fixeria 2 months ago

  • Assignee set to msuraev

#2 Updated by msuraev 2 months ago

Thank you for the patch. Right now we're using gerrit for code review and patch submission as described in here:
If you by any chance have some time - please submit it via gerrit (I recommend using git-review for convenience) otherwise I (or someone else) will take care of that but it might take somewhat longer.

Out of curiosity, could you share any details on your project? It's the first time I hear about anyone using libosmocore on Android. Would be cool to add this use-case to our CI setup to prevent this from reoccurring but that's a subject for another ticket of course.

#3 Updated by supersat 2 months ago

I've submitted the change to gerrit:

We are working on releasing an app called SeaGlass that uses cell_log and a OsmocomBB-compatible phone connected via USB OTG to scan for suspicious and rogue cell sites. Initially we ran osmocon as well, but that required a USB serial driver to be baked into the kernel as well as permissions set to access the device. We ended up rewriting some of the osmocon and USB driver functionality in Java (before we realized that Android's unix socket and USB APIs were somewhat lacking) so that we could access the USB port directly on unmodified phones.

The source code for that project is available here:

As for whether Android should be supported and tested, that sounds like a policy question. The comments in gsm_utils.c seems to suggest that eventually glibc 2.25+ will become a requirement.

#4 Updated by msuraev 2 months ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 50

The comments in gsm_utils.c seems to suggest that eventually glibc 2.25+ will become a requirement.

Let me clarify this since I was the one who wrote it initially: the part of the code in question deals with random id generation. We either make it via getrandom (1), via GnuTLS (2) or fallback to insecure random (3).

Option (1) requires GNU/Linux kernel and glibc which support getrandom. However, there's a trick which let's you use it when your kernel have getrandom implemented but glibc does not support it (it took quite some time for getrandom support to land in glibc). So the comment you're referring too is about that specific workaround for one particular option which indeed should be dropped once odd combination of kernel supporting getrandom with glibc not supporting it would become oddball instead of mainstream (which was the case when this code was merged).

The libosmocore however is also intended to be used in OsmocomBB (which ATM uses it's own copy of libosmocore because nobody had time yet to port it to master version) via '--enable-embedded' configure option which builds it without glibc.

To summarize, I don't think we'll have any glibc version as a strict dependency of libosmocore so Android SDK is a viable option in foreseeable future.

#5 Updated by msuraev 2 months ago

  • Status changed from In Progress to Resolved
  • % Done changed from 50 to 100

Fixed with 76f025eae8f642537886e879301561b5eb9bd6c6 commit.

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)