building libvpx for android with ndk-build

1,192 views
Skip to first unread message

Stijn Vanden Eynde

unread,
Oct 12, 2011, 6:31:56 AM10/12/11
to Codec Developers
Hello,

I encountered some errors while building the assembler files of the
libvpx source for android using ndk-build:
Depending on which .s-file I comes first in the list, I get the
following errors:

vp8/encoder/arm/neon/fastquantizeb_neon.s:151: Error: undefined symbol
vp8_blockd_eob used as an immediate value
vp8/encoder/arm/neon/fastquantizeb_neon.s:152: Error: undefined symbol
vp8_blockd_eob used as an immediate value
vp8/encoder/arm/neon/fastquantizeb_neon.s:241: Error: undefined symbol
vp8_blockd_eob used as an immediate value

vp8/encoder/arm/neon/subtract_neon.s:36: Error: internal_relocation
(type: OFFSET_IMM) not fixed up
vp8/encoder/arm/neon/subtract_neon.s:37: Error: internal_relocation
(type: OFFSET_IMM) not fixed up
vp8/encoder/arm/neon/subtract_neon.s:38: Error: internal_relocation
(type: OFFSET_IMM) not fixed up
vp8/encoder/arm/neon/subtract_neon.s:40: Error: internal_relocation
(type: OFFSET_IMM) not fixed up
vp8/encoder/arm/neon/subtract_neon.s:42: Error: internal_relocation
(type: OFFSET_IMM) not fixed up

vp8/encoder/arm/armv6/vp8_subtract_armv6.s:39: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_subtract_armv6.s:40: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_subtract_armv6.s:41: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_subtract_armv6.s:44: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_subtract_armv6.s:46: Error:
internal_relocation (type: OFFSET_IMM) not fixed up

vp8/encoder/arm/armv6/vp8_fast_quantize_b_armv6.s:33: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_fast_quantize_b_armv6.s:34: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_fast_quantize_b_armv6.s:35: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_fast_quantize_b_armv6.s:36: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_fast_quantize_b_armv6.s:37: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_fast_quantize_b_armv6.s:38: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_fast_quantize_b_armv6.s:116: Error:
internal_relocation (type: OFFSET_IMM) not fixed up
vp8/encoder/arm/armv6/vp8_fast_quantize_b_armv6.s:221: Error:
internal_relocation (type: OFFSET_IMM) not fixed up

I am using the latest git-version of the libvpx source.
I converted the .asm-files to .s-files using the ads2gas.pl file
provided in the libvpx source.

These are the generated files I use in my build:

ASM_FILES = \
vpx_scale/arm/neon/vp8_vpxyv12_copyframe_func_neon.s \
vpx_scale/arm/neon/vp8_vpxyv12_copyframeyonly_neon.s \
vpx_scale/arm/neon/vp8_vpxyv12_copysrcframe_func_neon.s \
vpx_scale/arm/neon/vp8_vpxyv12_extendframeborders_neon.s \
vp8/common/arm/armv6/bilinearfilter_v6.s \
vp8/common/arm/armv6/copymem8x4_v6.s \
vp8/common/arm/armv6/copymem8x8_v6.s \
vp8/common/arm/armv6/copymem16x16_v6.s \
vp8/common/arm/armv6/dc_only_idct_add_v6.s \
vp8/common/arm/armv6/iwalsh_v6.s \
vp8/common/arm/armv6/filter_v6.s \
vp8/common/arm/armv6/idct_v6.s \
vp8/common/arm/armv6/loopfilter_v6.s \
vp8/common/arm/armv6/recon_v6.s \
vp8/common/arm/armv6/simpleloopfilter_v6.s \
vp8/common/arm/armv6/sixtappredict8x4_v6.s \
vp8/common/arm/neon/bilinearpredict4x4_neon.s \
vp8/common/arm/neon/bilinearpredict8x4_neon.s \
vp8/common/arm/neon/bilinearpredict8x8_neon.s \
vp8/common/arm/neon/bilinearpredict16x16_neon.s \
vp8/common/arm/neon/copymem8x4_neon.s \
vp8/common/arm/neon/copymem8x8_neon.s \
vp8/common/arm/neon/copymem16x16_neon.s \
vp8/common/arm/neon/dc_only_idct_add_neon.s \
vp8/common/arm/neon/iwalsh_neon.s \
vp8/common/arm/neon/loopfilter_neon.s \
vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.s \
vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.s \
vp8/common/arm/neon/mbloopfilter_neon.s \
vp8/common/arm/neon/recon2b_neon.s \
vp8/common/arm/neon/recon4b_neon.s \
vp8/common/arm/neon/reconb_neon.s \
vp8/common/arm/neon/shortidct4x4llm_1_neon.s \
vp8/common/arm/neon/shortidct4x4llm_neon.s \
vp8/common/arm/neon/sixtappredict4x4_neon.s \
vp8/common/arm/neon/sixtappredict8x4_neon.s \
vp8/common/arm/neon/sixtappredict8x8_neon.s \
vp8/common/arm/neon/sixtappredict16x16_neon.s \
vp8/common/arm/neon/recon16x16mb_neon.s \
vp8/common/arm/neon/buildintrapredictorsmby_neon.s \
vp8/common/arm/neon/save_neon_reg.s \
vp8/encoder/arm/neon/sad8_neon.s \
vp8/encoder/arm/neon/sad16_neon.s \
vp8/encoder/arm/neon/shortfdct_neon.s \
vp8/encoder/arm/neon/variance_neon.s \
vp8/encoder/arm/neon/vp8_mse16x16_neon.s \
vp8/encoder/arm/neon/vp8_subpixelvariance8x8_neon.s \
vp8/encoder/arm/neon/vp8_subpixelvariance16x16_neon.s \
vp8/encoder/arm/neon/vp8_subpixelvariance16x16s_neon.s \
vp8/encoder/arm/neon/vp8_memcpy_neon.s \
vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.s \
vp8/decoder/arm/armv6/dequant_dc_idct_v6.s \
vp8/decoder/arm/armv6/dequant_idct_v6.s \
vp8/decoder/arm/armv6/dequantize_v6.s \
vp8/decoder/arm/neon/idct_dequant_dc_full_2x_neon.s \
vp8/decoder/arm/neon/idct_dequant_dc_0_2x_neon.s \
vp8/decoder/arm/neon/dequant_idct_neon.s \
vp8/decoder/arm/neon/idct_dequant_full_2x_neon.s \
vp8/decoder/arm/neon/idct_dequant_0_2x_neon.s \
vp8/decoder/arm/neon/dequantizeb_neon.s \
vp8/encoder/arm/armv6/vp8_short_fdct4x4_armv6.s \
vp8/encoder/arm/armv6/vp8_sad16x16_armv6.s \
vp8/encoder/arm/armv6/vp8_variance16x16_armv6.s \
vp8/encoder/arm/armv6/vp8_variance_halfpixvar16x16_h_armv6.s \
vp8/encoder/arm/armv6/vp8_variance_halfpixvar16x16_v_armv6.s \
vp8/encoder/arm/armv6/vp8_variance_halfpixvar16x16_hv_armv6.s \
vp8/encoder/arm/armv6/vp8_mse16x16_armv6.s \
vp8/encoder/arm/armv6/vp8_variance8x8_armv6.s \
vp8/encoder/arm/armv6/walsh_v6.s \
\
vp8/encoder/arm/neon/subtract_neon.s \
vp8/encoder/arm/neon/fastquantizeb_neon.s \
vp8/encoder/arm/armv6/vp8_subtract_armv6.s \
vp8/encoder/arm/armv6/vp8_fast_quantize_b_armv6.s \

LOCAL_SRC_FILES += $(ASM_FILES)

How can I solve these errors ?

Greetings,
Stijn Vanden Eynde

Johann Koenig

unread,
Oct 12, 2011, 12:42:02 PM10/12/11
to codec...@webmproject.org
On Wed, Oct 12, 2011 at 03:31, Stijn Vanden Eynde
<program...@gmail.com> wrote:
> vp8/encoder/arm/neon/fastquantizeb_neon.s:151: Error: undefined symbol
> vp8_blockd_eob used as an immediate value

These offsets are described in vp8/*/asm_*_offsets.c

If you're building these by hand, it would go something like:

<android_gcc> -S -I libvpx/ -DINLINE_ASM libvpx/vp8/common/asm_com_offsets.c
grep -w EQU asm_com_offsets.s | perl ads2gas.pl > asm_com_offsets.asm

see libvpx/build/make/Makefile:
.PRECIOUS: %.c.S
%.c.S: CFLAGS += -DINLINE_ASM
$(BUILD_PFX)%.c.S: %.c
$(if $(quiet),@echo " [GEN] $@")
$(qexec)$(CC) -S $(CFLAGS) -o $@ $<

and libvpx/libs.mk:
$(BUILD_PFX)asm_com_offsets.asm:
$(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S
grep -w EQU $< | tr -d '$$\#' $(ADS2GAS) > $@
$(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S:
$(VP8_PREFIX)common/asm_com_offsets.c
CLEAN-OBJS += $(BUILD_PFX)asm_com_offsets.asm
$(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S

for reference.
--
- johann koenig
  google

Fritz Koenig

unread,
Oct 12, 2011, 1:20:00 PM10/12/11
to codec...@webmproject.org
I have an experimental ndk build that uses the libvpx makefiles and
ndk in conjunction as to not need to create the file list by hand.

To use it put libvpx under jni, i.e. jni/libvpx. configure libvpx
from the jni directory. ./libvpx/configure --target=armv7-linux-gcc
--enable-error-concealment --disable-examples --enable-realtime-only

Then build as normal.

The big caveat is that you need the CodeSourcery tools installed to do
the configure. I haven't come up with a clean way around that yet.
The other caveat is that the processed assembler files are not stored
in the build tree, but under ads2gas. It's hard coded to armv7, but
that could be changed with the top include in Android.mk

> --
> You received this message because you are subscribed to the Google Groups "Codec Developers" group.
> To post to this group, send email to codec...@webmproject.org.
> To unsubscribe from this group, send email to codec-devel...@webmproject.org.
> For more options, visit this group at http://groups.google.com/a/webmproject.org/group/codec-devel/?hl=en.
>
>

Android.mk

Stijn Vanden Eynde

unread,
Oct 14, 2011, 11:55:57 AM10/14/11
to Codec Developers
Since ndk-build merely calls gcc, I could build libvpx by the usual
configure&make as well.
In my ubuntu environment I now have installed the CodeSourcery
toolchain and the latest libvpx source.
When I run the <libvpx>/configure script it recognizes the toolchain-
gcc as CC.
Building it succeed without errors.

Next I put the libvpx.so and libvpx.a in <eclipseproject>/jni/armeabi-
v7a/
In this project I made a jni-wrapper (myvp8encoder.cpp)
=== <eclipseproject>/jni/Android.mk ===
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := libvp8
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libvpx.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := libmyvp8encoder
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := myvp8encoder.cpp
LOCAL_SHARED_LIBRARIES := libvp8
include $(BUILD_SHARED_LIBRARY)
=== ===
"<eclipseproject>/jni/ndk-build -B" executes without errors.
(this ndk-build uses the toolchain-gcc that is in the ndk installation
dir)

But when I try to run my program on my smartphone (Android 2.3.3)
I get an UnsatisfiedLinkError: Cannot load library libpthread.so.0
The initial <libvpx>/configure also enables pthreads.

What am I doing wrong here ?

Johann Koenig

unread,
Oct 14, 2011, 3:20:24 PM10/14/11
to codec...@webmproject.org
On Fri, Oct 14, 2011 at 08:55, Stijn Vanden Eynde
<program...@gmail.com> wrote:
> When I run the <libvpx>/configure script it recognizes the toolchain-
> gcc as CC.

Are you specifying --target=armv[67]-linux-gcc --enable-pic

Stijn Vanden Eynde

unread,
Oct 17, 2011, 8:33:00 AM10/17/11
to Codec Developers
Johann,
the options I gave the configure script were:
--target=armv7-linux-gcc
--disable-examples
--enable-realtime-only
--enable-pic
--enable-error-concealment

I tried several things uptil now:
a) building libvpx using configure & make,
this build succeeds, but when I try to use it in an android app, it
results in an UnsatisfiedLinkError (libpthreads.so)
b) because the above failed I tried to build libvpx using ndk-build
(using a custom Android.mk)
this gave the errors i mentioned earlier in this thread.
c) I tried running the Android.mk of Fritz, but this also fails

Could you give me detailed steps on how to build it the right way ?

Many thanks
Stjn Vanden Eynde

On 14 okt, 21:20, Johann Koenig <johannkoe...@google.com> wrote:
> On Fri, Oct 14, 2011 at 08:55, Stijn Vanden Eynde
>

Attila Nagy

unread,
Oct 17, 2011, 10:15:30 AM10/17/11
to codec...@webmproject.org

Just guessing, is the dynamic lib properly installed on the device?

-Atti from mobile

Johann Koenig

unread,
Oct 17, 2011, 12:32:53 PM10/17/11
to codec...@webmproject.org
On Mon, Oct 17, 2011 at 05:33, Stijn Vanden Eynde
<program...@gmail.com> wrote:
> a) building libvpx using configure & make,
> this build succeeds, but when I try to use it in an android app, it
> results in an UnsatisfiedLinkError (libpthreads.so)

This thread deals with x86/android, but it may be useful:
http://groups.google.com/group/android-building/browse_thread/thread/3d56430b1c203634

Basically, add -lpthread to _LDFLAGS (probably LOCAL_LDFLAGS in the
parent applications Android.mk)

Attila Nagy

unread,
Oct 17, 2011, 12:51:14 PM10/17/11
to codec...@webmproject.org

Pthread is part of the android clib (lately?).  There is no -lpthread, and that is one reason why exec cannot be built by the libvpx make file. That might be the reason why the .so does not work either.

-Atti from mobile

Fritz Koenig

unread,
Oct 17, 2011, 2:16:05 PM10/17/11
to codec...@webmproject.org
On Mon, Oct 17, 2011 at 5:33 AM, Stijn Vanden Eynde
<program...@gmail.com> wrote:
> Johann,
> the options I gave the configure script were:
> --target=armv7-linux-gcc
> --disable-examples
> --enable-realtime-only
> --enable-pic
> --enable-error-concealment
>
> I tried several things uptil now:
> a) building libvpx using configure & make,
> this build succeeds, but when I try to use it in an android app, it
> results in an UnsatisfiedLinkError (libpthreads.so)
> b) because the above failed I tried to build libvpx using ndk-build
> (using a custom Android.mk)
> this gave the errors i mentioned earlier in this thread.
> c) I tried running the Android.mk of Fritz, but this also fails

Did this not build/link? If you give me some more info I may be able
to help. You do need to run configure first to get the header
files/.mk files built before running this.

>
> Could you give me detailed steps on how to build it the right way ?
>
> Many thanks
> Stjn Vanden Eynde
>
> On 14 okt, 21:20, Johann Koenig <johannkoe...@google.com> wrote:
>> On Fri, Oct 14, 2011 at 08:55, Stijn Vanden Eynde
>>
>> <programmer2...@gmail.com> wrote:
>> > When I run the <libvpx>/configure script it recognizes the toolchain-
>> > gcc as CC.
>>
>> Are you specifying --target=armv[67]-linux-gcc --enable-pic
>> --
>> - johann koenig
>>   google
>

Stijn Vanden Eynde

unread,
Oct 24, 2011, 6:07:06 AM10/24/11
to Codec Developers

On 17 okt, 20:16, Fritz Koenig <frkoe...@google.com> wrote:
>
> Did this not build/link?  If you give me some more info I may be able
> to help.  You do need to run configure first to get the header
> files/.mk files built before running this.

in <eclipse-project>/jni is your Android.mk present

<eclipse-project>/jni$ ./libvpx/configure \
--target=armv7-linux-gcc \
--enable-pic \
--enable-error-concealment \
--enable-realtime-only \
--disable-examples \
--enable-shared

<eclipse-project>/jni$ make
[ no errors, builds succesfully ]

<eclipse-project>/jni$ ndk-build -B
Compile arm : vpx <= vpx_config.c
make: *** No rule to make target `<eclipse-project>/jni/
vpx_interface.c', needed by `<eclipse-project>/obj/local/armeabi-v7a/
objs/vpx/vpx_interface.o'. Stop.

<eclipse-project>/jni$ find . -iname vpx_interface.c
[ no results ]

It's not much, but hopefully it helps.
Stijn Vanden Eynde
Reply all
Reply to author
Forward
0 new messages