4

Hi I am trying to port an OpenGL desktop app to android. I have no knowledge of android development so am depending on Qt Creator to package the app. As part of the setup, I have invoked 'make-standalone-toolchain' script in android ndk with following settings

--platform=android-21 
--toolchain=arm-linux-androideabi-4.9 
--system=linux-x86_64

Then I used android-cmake and passed it the path of my newly created standalone-toolchain, which created libassimp.so, libassimp.so.3, and libassimp.so.3.1.1(ln) inside my assimp directory tree.

I passed the libassimp.so path to Qt creator project build menu under 'additional libraries'. However, on deploying the app on android, it crashes with error:

 dlopen("/data/app/org.qtproject.example.a3dqtquick-2/lib/arm/lib3dqtquick.so", RTLD_LAZY) failed: dlopen failed: could not load library "libassimp.so.3" needed by "lib3dqtquick.so"; caused by library "libassimp.so.3" not found

I can even see the libassimp.so (not libassimp.so.3) file inside the project build directory at ../android-build/libs/armeabi-v7a.

Not sure where to go from here, manually placing libassimp.so.3 at this location does not sort out the problem. Thanks for reading. I will add further info on your feedback . please forgive any info deficiency as this is my first experiment with android.

Following is the deployment-settings.json file

  "description": "This file is generated by qmake to be read by androiddeployqt and should not be modified by hand.",
   "qt": "/home/ubashir/programs/Qt/5.4/android_armv7",
   "sdk": "/home/ubashir/programs/android-sdk-linux",
   "sdkBuildToolsRevision": "21.1.2",
   "ndk": "/home/ubashir/programs/android-ndk-r10d",
   "toolchain-prefix": "arm-linux-androideabi",
   "tool-prefix": "arm-linux-androideabi",
   "toolchain-version": "4.9",
   "ndk-host": "linux-x86_64",
   "target-architecture": "armeabi-v7a",
   "qml-root-path": "/home/ubashir/code/3dqtquick",
   "application-binary": "/home/ubashir/code/3dqtquickAndroid/lib3dqtquick.so" 

UPDATE:

I have now tried this.. replace all links to assimp.so.3.1.1 with copies of the latter so now my library libassimp.so.3 is a file instead of link to libassimp.so.3.1.1. I manually added libassimp.so.3 to my project subfolder android/libs/aremabi-v71 --- no good. I confirm that my build directory shows all libassimp files as I manually added them so presumably they are being deployed but the error remains :

failed: dlopen failed: could not load library "libassimp.so.3" needed by "lib3dqtquick.so".

As outlined here http://webmail.dev411.com/p/gg/android-ndk/1386vger6e/use-assimp-c-library-in-ndk-ld-error-obj-local-armeabi-v7a-libassimp-so-incompatible-target-for-use-with-vuforia

I even edited the link.txt file after running cmake on my assimp build directory for android, altering the entry -soname,libassimp.so.3 with -soname,libassimp.so but it still creates libassimp.so.3.1.1 with its two links , i.e., libassimp.so.3 and libassimp.so. So still stuck..

Maelstorm
  • 580
  • 2
  • 10
  • 29
  • Where the application calls `dlopen()` on the `lib3dqtquick.so` file, can you add another `dlopen()` just above it with the full path to the dependency? I'm just guessing, but perhaps the linker is looking for the `.so` in a different path and that's why it can't find it. – Aaron D Feb 06 '15 at 17:49
  • It sounds strange to me that you have to *manually* copy the library. Did you set `ANDROID_EXTRA_LIBS` in the `.pro` file? – BaCaRoZzo Feb 08 '15 at 11:28
  • I used both , ANDROID_EXTRA_LIBS, and manual, as it seems the former does not add files suffixed .so.3 – Maelstorm Feb 08 '15 at 16:49
  • Mh, quite strange. I've always deployed libraries created in Qt Creator so I can't tell for libs created directly with the ndk. Would be interesting to dig into. – BaCaRoZzo Feb 09 '15 at 11:45

2 Answers2

0

I ran into the same problem with a shared library I built with CMake for and Android project. I found a way to fix it. There might be a cleaner solution if you were more familiar with CMake.

Search through the CMakeLists.txt file(s) for "SOVERSION" and "SET_TARGET_PROPERTIES()"

In the SET_TARGET_PROPERTIES() routine comment out the lines for VERSION and SOVERSION as follows

SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES                # create *nix style library versions + symbolic links
    DEFINE_SYMBOL DSO_EXPORTS
        #   VERSION ${PROJECT_VERSION}
        #   SOVERSION ${PROJECT_SOVERSION}
    CLEAN_DIRECT_OUTPUT 1                   # allow creating static and shared libs without conflicts
    OUTPUT_NAME "${PROJECT_NAME}${PROJECT_DLLVERSION}"  # avoid conflicts between library and binary target names
)

Then rerun the configure and generate steps in CMake and rebuild the target. This should give you a .so without any version numbers.

Ken
  • 309
  • 2
  • 11
-1

I'll suggest you to take a look at the solution I've found to my problem (that is very similar to yours):

libgdal.so android error: could not load library "libgdal.so.1"

Hope this helps.

Community
  • 1
  • 1
arms
  • 163
  • 1
  • 3
  • 9
  • Thanks for the tip. I have read your post and updated my question with steps i undertook. assimp uses cmake system and your project is based on libtools so i could not entirely replicate your steps. – Maelstorm Jan 30 '15 at 02:03