Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ndk-build fails to build Superpowered audio library after recent NDK update

UPDATE March 19, 2016: Superpowered has released new binaries which work properly with NDK r11

I'm trying to build Superpowered library CrossExample sample project in Android Studio. Until recent NDK update it worked like charm, but now execution of ndk-build gives an error:

Error:error: undefined reference to '__page_size'

I tried building with different toolchains, removing/adding several build flags with no luck so far.

In a different project that uses Superpowered SDK and pretty much the same config I get some other error details. Part of output message log:

/android/ndk/platforms/android-9/arch-x86/usr/include/unistd.h:173: error: undefined reference to '__page_size'
/android/ndk/platforms/android-9/arch-x86/usr/include/unistd.h:173: error: undefined reference to '__page_size'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/user_name/StudioProjects/project_name/app/src/main/jniSuperpowered/obj/local/x86/libNativeLibName.so] Error 1
make: *** Waiting for unfinished jobs....
/Volumes/iMect/iphone/SuperpoweredSource/decoder/SuperpoweredDecoder.cpp:120: error: undefined reference to '__page_size'
/Volumes/iMect/iphone/SuperpoweredSource/decoder/hlsreader.cpp:582: error: undefined reference to '__page_size'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/user_name/StudioProjects/project_name/app/src/main/jniSuperpowered/obj/local/armeabi-v7a/libNightcorizerSuperpowered.so] Error 1
FAILURE: Build failed with an exception.

What looks not right is undefined reference to __page_size in unistd.h . However I've got very little idea of further troubleshooting.

Thanks ahead for any help/suggestions!

like image 674
Sam Avatar asked Mar 15 '16 04:03

Sam


2 Answers

The changes made in this NDK commit seem to explain the issue you're seeing. According to the commit description, __page_size was replaced with PAGE_SIZE for Android API levels 12 and under. As you're using API level 9 and code which directly references __page_size, you're seeing an effect from this change.

However, it looks like the method signature for int getpagesize() hasn't changed across NDK versions or across API levels, so you should be able to resolve this error by replacing the usage of __page_size with getpagesize() in the following locations:

SuperpoweredSource/decoder/SuperpoweredDecoder.cpp:120 SuperpoweredSource/decoder/hlsreader.cpp:582

Update: To fix it without modifying the Superpowered source code, you'd need to define the symbol __page_size. To do that, you could build a tiny dummy library which just contains

#include <unistd.h>
extern unsigned int __page_size = getpagesize();

Then, add a module for this library to your Android.mk (or your build.gradle if you're using the new experimental system) and make the module for Superpowered depend on the dummy module.

Or, you could file a bug report with Superpowered.

like image 185
Francesca Nannizzi Avatar answered Sep 24 '22 00:09

Francesca Nannizzi


So as a workaround for the situation I reverted NDK to r10e which worked. Will be using it until Superpowered library gets a fix. Great thanks to @bullsy

like image 38
Sam Avatar answered Sep 26 '22 00:09

Sam