Error: dlopen failed: /data/app/com.myapp-1/lib/x86/libmpg123.so: has text relocations

I have added next lines to the SDL2_mixer/external/mpg123-1.25.6/Android.mk

LOCAL_LDLIBS :=
LOCAL_LDFLAGS :=

LOCAL_LDFLAGS += -fPIC

LOCAL_LDLIBS += -Wl,--no-warn-shared-textrel

LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true

Now I can build my app successfully but on the virtual device I get error:

dlopen failed: /data/app/com.myapp-1/lib/x86/libmpg123.so: has text relocations

How to fix it?

I have answered this in your other thread. I don’t think you will get answers any more quickly by creating new threads containing the same question, in fact it is confusing.

In my other thread I had another issue which was related to “text relocations”. At that time I can’t build my app. At this time I can build with your help from my another thread but can’t run my app. So, I asked new question.

Sorry about some kind of flooding from me, but I am pretty sure this new thread could help someone else to port his game to android with a less pain.

Guys, I want to thank you, because you had created an incredible cross-platform library.

I had almost 10 years of experience in web development (php, javascript) but I am a newby in game development. I had successfully build and run a game with SDL2, SDL2_image and SDL2_mixer on desktop (linux) but porting it to the android is very hard to me. I asked a lot of questions because all books I had read was written for eclipse and older version of android and there is no so much information about porting SDL2 and related libs to the android. I asked this questions with hope that it will help another newby like me.

My understanding is that it’s all the same issue. You were initially getting a warning at build time about Text Relocations (TEXTRELs) in shareable libraries; having suppressed that warning you were then getting a fatal error at install time because such relocations have been disallowed since Android API Level 23.

This is supposedly because relocatable libraries need to go in writable memory pages, to allow the fixups to be made, and this somehow weakens security. Personally I don’t find this a convincing argument; once the fixups have been made during installation the pages can surely be changed to read-only. As far as I know this is how it works in most other Operating Systems.

The trouble is that the (32-bit) x86 instruction set doesn’t make creating Position Independent Code (PIC) easy; there’s an overhead of both code size and execution time. If the code has been written in assembly language (which mine has) converting it to be Position Independent may be impractical. As a result my app simply won’t install on x86 Android Marshmallow or later.

Richard.

1 Like