Using `androidndk` for compilation of `react-native-webgl` module

Hi,

I’m trying to compile react-native-webgl module. I’ve spent a lot of time during last week trying to start my first serious react-native app. Unfortunately I was not able to compile my example app.
I want to warn all readers that I’m also NixOs newbie and not an expert of C++ compilation process, so I’m probably writing a lot of stupid things here.

ENVIRONMENT

This module comes with this android build file (I’m not really familiar with android build stack yet):

I’m using FHS and android related packages in my environment. Here is my react-native-webgl.nix which is nothing more than androidsdk + buildTools 25.0.1 and simple autolicensing patch:

To build I’m creating simple react-native project, but it doesn’t really matter in this context as I’ve tracked problems down to compiling and linking gl bindings of react-native-webgl.

RESULTS

During armeabi-v7a compilation I’m getting:

Bad value

from

arm-linux-androideabi-strip

If I try to compile only for x86 architecture I’m getting error from linking step:

fatal error: -shared and -static are incompatible

from ld

(exactly from: /nix/store/...-android-ndk-r17/libexec/android-ndk-r17/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld)

QUESTIONS

I’m not sure but it seems that I have to patch some additional libraries as above Application.mk contains:

APP_LDFLAGS += -llog
APP_LDFLAGS += -lGLESv2
APP_LDFLAGS += -ljnigraphics

I’ve tried to add some additional patching to my project expression but it doesn’t work.

Do you have any suggestion how to patch above libraries?

As far as I understand I should patch them for x86. Does arm build also require such a patching?

Do you have any propositions how should I debug this further?

The first thing you need to find out, is what parameter does arm-linux-androideabi-strip receive, when it prints that value. One trick I use is strace -s 512 -e execve -f followed by the build command. This will print all commands with all arguments that are executed. From there you will also see the binary that is given to the strip command. You can use readelf and nm to inspect the binary. The binary might be broken.
For the link command (ld), you should check where it adds both -shared and -static parameter. You can also use strace again to get the whole executed command.

1 Like

Wow! Thanks a lot for suggestions @Mic92! I’m going to investigate this further with this arsenal of tools.