[osg-users] [build] OpenSceneGraph static linking for Android
Kamil Zaripov
kamil at zaripov.net
Thu Sep 21 05:55:51 PDT 2017
Hi,
I'm trying to compile static OpenSceneGraph for Android. However, when I'm trying to open simple .osg model, osg says that it can't load osgPlugins-3.4.0/osgdb_osg.so.
Host OS: macOS 10.12.6
CMake version 3.9.0
OpenSceneGraph version 3.4.0
Android NDK version r14b
CMake configuration:
Code:
cmake ../OpenSceneGraph \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX=../OpenSceneGraph-android-static \
-DCMAKE_SYSTEM_NAME="Android" \
-DCMAKE_SYSTEM_VERSION=17 \
-DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a \
-DCMAKE_ANDROID_NDK=/Users/kamil/Library/Android/sdk/ndk-bundle \
-DOPENGL_PROFILE="GLES2" \
-DDYNAMIC_OPENTHREADS=OFF \
-DDYNAMIC_OPENSCENEGRAPH=OFF
I'm linking OpenSceneGraph libraries to my project qmake file as follows:
my-project.pro:
Code:
...
LIBS += $${OPENSCENEGRAPHPATH}/lib/osgPlugins-3.4.0/libosgdb_osg.a \
$${OPENSCENEGRAPHPATH}/lib/libosgViewer.a \
$${OPENSCENEGRAPHPATH}/lib/libosgDB.a \
$${OPENSCENEGRAPHPATH}/lib/libosgGA.a \
$${OPENSCENEGRAPHPATH}/lib/libosgText.a \
$${OPENSCENEGRAPHPATH}/lib/libosgUtil.a \
$${OPENSCENEGRAPHPATH}/lib/libosgShadow.a \
$${OPENSCENEGRAPHPATH}/lib/libosgTerrain.a \
$${OPENSCENEGRAPHPATH}/lib/libosgSim.a \
$${OPENSCENEGRAPHPATH}/lib/libosg.a \
$${OPENSCENEGRAPHPATH}/lib/libOpenThreads.a
INCLUDEPATH += $${OPENSCENEGRAPHPATH}/include
LIBS += $${OPENSCENEGRAPHPATH}/obj/local/armeabi-v7a/libcurl.a \
$${OPENSCENEGRAPHPATH}/obj/local/armeabi-v7a/libgdal.a \
$${OPENSCENEGRAPHPATH}/obj/local/armeabi-v7a/libft2.a \
$${OPENSCENEGRAPHPATH}/obj/local/armeabi-v7a/libgif.a \
$${OPENSCENEGRAPHPATH}/obj/local/armeabi-v7a/libjpeg.a \
$${OPENSCENEGRAPHPATH}/obj/local/armeabi-v7a/libpng.a \
$${OPENSCENEGRAPHPATH}/obj/local/armeabi-v7a/libtiff.a
...
In my main.cpp I've used USE_OSGPLUGIN macro to link osg plugin:
main.cpp:
Code:
#include <osgDB/Registry>
...
USE_OSGPLUGIN(osg)
...
int main() {
...
}
However, when I'm trying to open some osg file:
Code:
osg::Node * node = osgDB::readNodeFile(":/resources/cessna.osg");
osgDB::readNodeFile returns NULL and prints in output:
Code:
Warning: dynamic library 'osgPlugins-3.4.0/osgdb_osg.so' does not exist (or isn't readable):
dlopen failed: library "osgPlugins-3.4.0/osgdb_osg.so" not found
DynamicLibrary::failed loading "osgPlugins-3.4.0/osgdb_osg.so"
What should I do to correctly link OpenSceneGraph library for Android?
Thank you!
Cheers,
Kamil
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71406#71406
More information about the osg-users
mailing list