[osg-users] Android osgPlugins

179 views
Skip to first unread message

Nathan Collins

unread,
Jan 9, 2014, 12:00:29 PM1/9/14
to osg-...@lists.openscenegraph.org

Hi,

 

I have compiled OSG for Android, and built and deployed the GLES2 Android example on my Nexus 4. However I’m having trouble loading cow.osg, or any other .osg/.osgt files, to test that it works. I’ve built OSG for Android in the past and had these models working but this time around I’m not able to load any models at all. I get the following warnings from logcat:

 

01-09 16:46:11.812: E/Osg Viewer(18327): There are 1 models to load

01-09 16:46:11.812: E/Osg Viewer(18327): Loading: /storage/emulated/0/cow.osgt

01-09 16:46:11.812: D/Osg Viewer(18327): FindFileInPath(/storage/emulated/0/cow.osgt): returning /storage/emulated/0/cow.osgt

01-09 16:46:11.812: D/Osg Viewer(18327): itr='/vendor/lib'

01-09 16:46:11.812: D/Osg Viewer(18327): FindFileInPath() : trying /vendor/lib/osgPlugins-3.2.1/osgdb_osg.so ...

01-09 16:46:11.812: D/Osg Viewer(18327): itr='/system/lib'

01-09 16:46:11.812: D/Osg Viewer(18327): FindFileInPath() : trying /system/lib/osgPlugins-3.2.1/osgdb_osg.so ...

01-09 16:46:11.812: D/Osg Viewer(18327): itr='/usr/lib/'

01-09 16:46:11.812: D/Osg Viewer(18327): FindFileInPath() : trying /usr/lib/osgPlugins-3.2.1/osgdb_osg.so ...

01-09 16:46:11.812: D/Osg Viewer(18327): itr='/usr/local/lib/'

01-09 16:46:11.812: D/Osg Viewer(18327): FindFileInPath() : trying /usr/local/lib/osgPlugins-3.2.1/osgdb_osg.so ...

01-09 16:46:11.812: D/Osg Viewer(18327): itr='/vendor/lib'

01-09 16:46:11.812: D/Osg Viewer(18327): FindFileInPath() : trying /vendor/lib/osgdb_osg.so ...

01-09 16:46:11.812: D/Osg Viewer(18327): itr='/system/lib'

01-09 16:46:11.812: D/Osg Viewer(18327): FindFileInPath() : trying /system/lib/osgdb_osg.so ...

01-09 16:46:11.812: D/Osg Viewer(18327): itr='/usr/lib/'

01-09 16:46:11.812: D/Osg Viewer(18327): FindFileInPath() : trying /usr/lib/osgdb_osg.so ...

01-09 16:46:11.812: D/Osg Viewer(18327): itr='/usr/local/lib/'

01-09 16:46:11.812: D/Osg Viewer(18327): FindFileInPath() : trying /usr/local/lib/osgdb_osg.so ...

01-09 16:46:11.812: I/Osg Viewer(18327): Warning: dynamic library 'osgPlugins-3.2.1/osgdb_osg.so' does not exist (or isn't readable):

01-09 16:46:11.812: I/Osg Viewer(18327): dlopen failed: library "osgPlugins-3.2.1/osgdb_osg.so" not found

01-09 16:46:11.812: I/Osg Viewer(18327): DynamicLibrary::failed loading "osgPlugins-3.2.1/osgdb_osg.so"

01-09 16:46:11.812: E/Osg Viewer(18327): Model not loaded

 

Now I thought I didn’t have to do anything special last time to load an .osg file but I’m wondering what I’ve missed? My Android.mk file just has the standard set OSG_ANDROID_DIR and add path/to/libgnustl_static.a in LOCAL_LDLIBS modifications. I’m working with OSG branch 3.2 on Fedora, with ndk-r9c.

 

Any help would be greatly appreciated. Thanks,

 

Nathan

 

Nathan Collins
Software Engineer
________________________________
Have you downloaded your FREE copy of FieldMove Clino?
Find out more about our app for iPhone and Android smartphones:  http://news.mve.com/fieldmoveclino

Midland Valley Exploration Ltd.
144 West George Street
Glasgow G2 2HG
United Kingdom

Tel:     +44 (0) 141 332 2681
Fax:    +44 (0) 141 332 6792

The structural geology experts

 

Jordi Torres

unread,
Jan 9, 2014, 12:13:29 PM1/9/14
to OpenSceneGraph Users
Hi Nathan, 

Did you compile OSG in static mode as stated in the documentation?

-DDYNAMIC_OPENTHREADS=OFF
-DDYNAMIC_OPENSCENEGRAPH=OFF 

Right now is a must to compile in static mode. We have some tests with dynamic libraries but compiling in dynamic mode involves too many changes and we have still work to do to make it public. 

Hope it helps. 


2014/1/9 Nathan Collins <nat...@mve.com>
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




--
Jordi Torres


Nathan Collins

unread,
Jan 10, 2014, 4:23:32 AM1/10/14
to OpenSceneGraph Users
Hi Jordi,

thanks for getting back to me. I did compile with OSG in static mode. Here are the flags I'm using:

OSG_GLES2_VARS="-DOSG_GL1_AVAILABLE=OFF \
-DOSG_GL2_AVAILABLE=OFF \
-DOSG_GL3_AVAILABLE=OFF \
-DOSG_GLES1_AVAILABLE=OFF \
-DOSG_GLES2_AVAILABLE=ON \
-DOSG_GL_LIBRARY_STATIC=OFF \
-DOSG_GL_DISPLAYLISTS_AVAILABLE=OFF \
-DOSG_GL_MATRICES_AVAILABLE=OFF \
-DOSG_GL_VERTEX_FUNCS_AVAILABLE=OFF \
-DOSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE=OFF \
-DOSG_GL_FIXED_FUNCTION_AVAILABLE=OFF"

OSG_ANDROID_VARS="-DDYNAMIC_OPENTHREADS=OFF \
-DDYNAMIC_OPENSCENEGRAPH=OFF \
-DOSG_BUILD_PLATFORM_ANDROID=ON \
-DANDROID_ABI=\"armeabi armeabi-v7a\" \
-DANDROID_PLATFORM=7 \
-DANDROID_STL="gnustl_static" \
-DANDROID_DEBUG=OFF \
-DANDROID_NDK=${ANDROID_NDK_ROOT} \
-DJ=12"

cmake ${OSG_ANDROID_VARS} ${OSG_GLES2_VARS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${GLOBAL_OUTDIR}/osg-${VERSION}/${TOOLCHAIN}"

I wondered about that too, because OSG is searching for a dynamic library in osgPlugins-3.2.1/ directories. I thought I didn't need to add this directory with the plugins on to my device. As far as I can see I don't have an osgPlugings directory produced by my OSG build for Android in the same way I would for PC. Is this something I need to do? If so I would appreciate a link to any instructions available.

Thanks,
Nathan

From: osg-user...@lists.openscenegraph.org [osg-user...@lists.openscenegraph.org] on behalf of Jordi Torres [jtorre...@gmail.com]
Sent: 09 January 2014 17:13
To: OpenSceneGraph Users
Subject: Re: [osg-users] Android osgPlugins

Christian Kehl

unread,
Apr 13, 2015, 5:40:13 AM4/13/15
to osg-...@lists.openscenegraph.org
Hi Jordi,

I encounter the same problem in the same situation. I've build OSG for
Android in static mode (only way it even compiles), all static libraries
(for me: .a-files) are in my local installation folder, together with the
libraries for armeabi and armeabi-v7a from the Android Native Developer Kit.
It compiles fine, I can change the background of the viewer without
problems, but it just doesn't wanna load the models. I get the same logcat
messages as mentioned before (not finding the plugins). I, up until now,
loaded files from the internal HDD of the phone (I am on Nexus 5), but today
also try out the sdcard as source. Are there any suggestions how to solve
the problem ?

Jan Ciger

unread,
Apr 13, 2015, 6:03:30 AM4/13/15
to OpenSceneGraph Users

On Mon, Apr 13, 2015 at 11:16 AM, Christian Kehl <Christi...@uni.no> wrote:
Hi Jordi,

I encounter the same problem in the same situation. I've build OSG for
Android in static mode (only way it even compiles), all static libraries
(for me: .a-files) are in my local installation folder, together with the
libraries for armeabi and armeabi-v7a from the Android Native Developer Kit.
It compiles fine, I can change the background of the viewer without
problems, but it just doesn't wanna load the models. I get the same logcat
messages as mentioned before (not finding the plugins). I, up until now,
loaded files from the internal HDD of the phone (I am on Nexus 5), but today
also try out the sdcard as source. Are there any suggestions how to solve
the problem ?



Did you:

a) Link the plugins into your JNI code? This is needed because the libraries are static, thus it cannot load them dynamically at runtime. It is a workaround for complicated deployment on Android.

b) Declared which plugins you are using? Again, this is linked to the point above, because the plugin registration has to be done at compile time when using static linking. Make sure that you have something like this in your code (add/remove the plugins you need/don't need):


//Static plugins Macro
USE_OSGPLUGIN(ive)
USE_OSGPLUGIN(osg)
USE_OSGPLUGIN(osg2)
USE_OSGPLUGIN(freetype)
//USE_OSGPLUGIN(terrain)
USE_OSGPLUGIN(rgb)
//USE_OSGPLUGIN(OpenFlight)
//USE_OSGPLUGIN(dds)

//Static DOTOSG
USE_DOTOSGWRAPPER_LIBRARY(osg)
//USE_DOTOSGWRAPPER_LIBRARY(osgFX)
//USE_DOTOSGWRAPPER_LIBRARY(osgParticle)
//USE_DOTOSGWRAPPER_LIBRARY(osgTerrain)
USE_DOTOSGWRAPPER_LIBRARY(osgText)
USE_DOTOSGWRAPPER_LIBRARY(osgAnimation)
//USE_DOTOSGWRAPPER_LIBRARY(osgViewer)
//USE_DOTOSGWRAPPER_LIBRARY(osgVolume)

//Static serializer
USE_SERIALIZER_WRAPPER_LIBRARY(osg)
USE_SERIALIZER_WRAPPER_LIBRARY(osgAnimation)
//USE_SERIALIZER_WRAPPER_LIBRARY(osgFX)
USE_SERIALIZER_WRAPPER_LIBRARY(osgManipulator)
//USE_SERIALIZER_WRAPPER_LIBRARY(osgParticle)
//USE_SERIALIZER_WRAPPER_LIBRARY(osgTerrain)
USE_SERIALIZER_WRAPPER_LIBRARY(osgText)
//USE_SERIALIZER_WRAPPER_LIBRARY(osgVolume)

Without this sort of declaration and the corresponding linking statement it will not work when built as a fully static library.

J.


























Christian Kehl

unread,
Apr 15, 2015, 10:16:18 AM4/15/15
to osg-...@lists.openscenegraph.org
Jan Ciger <jan.ciger@...> writes:

>
>
>
> On Mon, Apr 13, 2015 at 11:16 AM, Christian Kehl <Christian.Kehl <at>
Hi,

I had a look on the OsgMainApp.hpp, where these plugin links are all active
(looks as follows):

//Static plugins Macro
USE_OSGPLUGIN(ive)
USE_OSGPLUGIN(osg)
USE_OSGPLUGIN(osg2)
USE_OSGPLUGIN(terrain)
USE_OSGPLUGIN(rgb)
USE_OSGPLUGIN(OpenFlight)
USE_OSGPLUGIN(dds)
//Static DOTOSG
USE_DOTOSGWRAPPER_LIBRARY(osg)
USE_DOTOSGWRAPPER_LIBRARY(osgFX)
USE_DOTOSGWRAPPER_LIBRARY(osgParticle)
USE_DOTOSGWRAPPER_LIBRARY(osgTerrain)
USE_DOTOSGWRAPPER_LIBRARY(osgText)
USE_DOTOSGWRAPPER_LIBRARY(osgViewer)
USE_DOTOSGWRAPPER_LIBRARY(osgVolume)
//Static serializer
USE_SERIALIZER_WRAPPER_LIBRARY(osg)
USE_SERIALIZER_WRAPPER_LIBRARY(osgAnimation)
USE_SERIALIZER_WRAPPER_LIBRARY(osgFX)
USE_SERIALIZER_WRAPPER_LIBRARY(osgManipulator)
USE_SERIALIZER_WRAPPER_LIBRARY(osgParticle)
USE_SERIALIZER_WRAPPER_LIBRARY(osgTerrain)
USE_SERIALIZER_WRAPPER_LIBRARY(osgText)
USE_SERIALIZER_WRAPPER_LIBRARY(osgVolume)

if one of them would go wrong, my JNI-compiler would mourn, I presume ?
Hence, the links are active, still the models are not loaded.

At the moment, I follow this approach:
go on the commandline to my workdirectory,
execute "<path-to-ndk>/ndk-build", then go to eclipse,
hit "start" and try out the app.
May that be a cause for problems ?

Christian Kehl

unread,
Apr 15, 2015, 10:29:50 AM4/15/15
to osg-...@lists.openscenegraph.org
Jan Ciger <jan.ciger@...> writes:

>
>
>
> On Mon, Apr 13, 2015 at 11:16 AM, Christian Kehl <Christian.Kehl <at>
uni.no> wrote:Hi Jordi,
> I encounter the same problem in the same situation. I've build OSG for
> Android in static mode (only way it even compiles), all static libraries
> (for me: .a-files) are in my local installation folder, together with the
> libraries for armeabi and armeabi-v7a from the Android Native Developer Kit.
> It compiles fine, I can change the background of the viewer without
> problems, but it just doesn't wanna load the models. I get the same logcat
> messages as mentioned before (not finding the plugins). I, up until now,
> loaded files from the internal HDD of the phone (I am on Nexus 5), but today
> also try out the sdcard as source. Are there any suggestions how to solve
> the problem ?
>
>
>
>
> Did you:
>
> a) Link the plugins into your JNI code? This is needed because the
libraries are static, thus it cannot load them dynamically at runtime. It is
a workaround for complicated deployment on Android.
>

>
> Without this sort of declaration and the corresponding linking statement
it will not work when built as a fully static library.
>
> J.

I also append the output of the ndk-build, in case this may give some
indication what goes wrong there ...

christian@PROMETHEUS:~/workspace/Android/osgViewer2$ ${ANDROID_NDK}/ndk-build
Android NDK: WARNING:jni/Android.mk:osgNativeLib: non-system libraries in
linker flags: -lgnustl_static -lcurl -ljpeg -lgif -lpng -ltiff -losgdb_dds
-losgdb_openflight -losgdb_tga -losgdb_rgb -losgdb_osgterrain -losgdb_osg
-losgdb_ive -losgdb_deprecated_osgviewer -losgdb_deprecated_osgvolume
-losgdb_deprecated_osgtext -losgdb_deprecated_osgterrain
-losgdb_deprecated_osgsim -losgdb_deprecated_osgshadow
-losgdb_deprecated_osgparticle -losgdb_deprecated_osgfx
-losgdb_deprecated_osganimation -losgdb_deprecated_osg
-losgdb_serializers_osgvolume -losgdb_serializers_osgtext
-losgdb_serializers_osgterrain -losgdb_serializers_osgsim
-losgdb_serializers_osgshadow -losgdb_serializers_osgparticle
-losgdb_serializers_osgmanipulator -losgdb_serializers_osgfx
-losgdb_serializers_osganimation -losgdb_serializers_osg -losgViewer
-losgVolume -losgTerrain -losgText -losgShadow -losgSim -losgParticle
-losgManipulator -losgGA -losgFX -losgDB -losgAnimation -losgUtil -losg
-lOpenThreads
Android NDK: This is likely to result in incorrect builds. Try using
LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library
dependencies of the
Android NDK: current module
Android NDK: WARNING:jni/Android.mk:osgNativeLib: non-system libraries in
linker flags: -lgnustl_static -lcurl -ljpeg -lgif -lpng -ltiff -losgdb_dds
-losgdb_openflight -losgdb_tga -losgdb_rgb -losgdb_osgterrain -losgdb_osg
-losgdb_ive -losgdb_deprecated_osgviewer -losgdb_deprecated_osgvolume
-losgdb_deprecated_osgtext -losgdb_deprecated_osgterrain
-losgdb_deprecated_osgsim -losgdb_deprecated_osgshadow
-losgdb_deprecated_osgparticle -losgdb_deprecated_osgfx
-losgdb_deprecated_osganimation -losgdb_deprecated_osg
-losgdb_serializers_osgvolume -losgdb_serializers_osgtext
-losgdb_serializers_osgterrain -losgdb_serializers_osgsim
-losgdb_serializers_osgshadow -losgdb_serializers_osgparticle
-losgdb_serializers_osgmanipulator -losgdb_serializers_osgfx
-losgdb_serializers_osganimation -losgdb_serializers_osg -losgViewer
-losgVolume -losgTerrain -losgText -losgShadow -losgSim -losgParticle
-losgManipulator -losgGA -losgFX -losgDB -losgAnimation -losgUtil -losg
-lOpenThreads
Android NDK: This is likely to result in incorrect builds. Try using
LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library
dependencies of the
Android NDK: current module
[armeabi] Compile++ thumb: osgNativeLib <= osgNativeLib.cpp
[armeabi] Compile++ thumb: osgNativeLib <= OsgMainApp.cpp
[armeabi] Compile++ thumb: osgNativeLib <= OsgAndroidNotifyHandler.cpp
[armeabi] SharedLibrary : libosgNativeLib.so
[armeabi] Install : libosgNativeLib.so => libs/armeabi/libosgNativeLib.so
[armeabi-v7a] Compile++ thumb: osgNativeLib <= osgNativeLib.cpp
[armeabi-v7a] Compile++ thumb: osgNativeLib <= OsgMainApp.cpp
[armeabi-v7a] Compile++ thumb: osgNativeLib <= OsgAndroidNotifyHandler.cpp
[armeabi-v7a] SharedLibrary : libosgNativeLib.so
[armeabi-v7a] Install : libosgNativeLib.so =>
libs/armeabi-v7a/libosgNativeLib.so

Jan Ciger

unread,
Apr 15, 2015, 11:56:22 AM4/15/15
to OpenSceneGraph Users


Hello Christian,
That looks sensible to me.

 

At the moment, I follow this approach:
go on the commandline to my workdirectory,
execute "<path-to-ndk>/ndk-build", then go to eclipse,
hit "start" and try out the app.
May that be a cause for problems ?

No not really. That is pretty much how it should be built.

It would be best to turn on debugging and check where exactly it fails. It could also be that you don't have osgDB compiled statically for some reason - it was looking for its shared library. Does it load an .ive or .osg file? Or no files at all?

J.




Christian Kehl

unread,
Apr 16, 2015, 9:33:57 AM4/16/15
to osg-...@lists.openscenegraph.org
Jan Ciger <jan.ciger@...> writes:


It load's nothing at all, no matter the size. I tried out cessna.osg and
cow.osg from the sample set, an indoor .wrl-model I have (just one blank
wall, 100MB), a larger 3ds file - all run fine on the desktop but not a
single model loads on mobile. I try it currently out with the Nexus 5 and
the NVIDIA Shield tablet - same results at both.

How do I make sure it uses the ".a"-files (static libraries) ? I just used
the Android.mk that is shipped with the example, added -lgnustl..., as
written in all blogs to the topic, set the OSG_ANDROID_DIR to the location
of the local OSG_Android root install location (the folder with "bin" and
"lib" inside). As ndk-build reports, LOCAL_STATIC_LIBRARIES is not set in
the Android.mk, instead all libraries are referred in LOCAL_LDFLAGS.

Jan Ciger

unread,
Apr 16, 2015, 12:08:44 PM4/16/15
to OpenSceneGraph Users

On Thu, Apr 16, 2015 at 3:33 PM, Christian Kehl <Christi...@uni.no> wrote:
How do I make sure it uses the ".a"-files (static libraries) ?

Check whether you have any .so files generated for OSG. You shouldn't have any, only .a libraries.

J.



Christian Kehl

unread,
Apr 17, 2015, 7:32:57 AM4/17/15
to osg-...@lists.openscenegraph.org
Jan Ciger <jan.ciger@...> writes:

>
>
>
> On Thu, Apr 16, 2015 at 3:33 PM, Christian Kehl <Christian.Kehl <at>
uni.no> wrote:
> How do I make sure it uses the ".a"-files (static libraries) ?
>
> Check whether you have any .so files generated for OSG. You shouldn't have
any, only .a libraries.
>
> J.
>
>
>
>
>
>

checked - only ".a" files available. No shared objects/dynamic libraries
build, all static.

Jan Ciger

unread,
Apr 17, 2015, 11:11:34 AM4/17/15
to OpenSceneGraph Users

On Fri, Apr 17, 2015 at 1:26 PM, Christian Kehl <Christi...@uni.no> wrote:

checked - only ".a" files available. No shared objects/dynamic libraries
build, all static.


Then I am really at the end with ideas :( Perhaps Jordi will know what could be going on there.

J.

Christian Kehl

unread,
Apr 20, 2015, 4:35:03 AM4/20/15
to osg-...@lists.openscenegraph.org
Jan Ciger <jan.ciger@...> writes:

>
>
>
> On Fri, Apr 17, 2015 at 1:26 PM, Christian Kehl <Christian.Kehl <at>
uni.no> wrote:
> checked - only ".a" files available. No shared objects/dynamic libraries
> build, all static.
>
>
> Then I am really at the end with ideas :( Perhaps Jordi will know what
could be going on there.
>
> J.
>


Hi,

is there still anybody available who has an idea what could be wrong in this
instance ? The problem continues to persist and I don't know enough about
the android wrapping system to fix the problem myself. The problem has to be
in the static libraries, but where ?

Kind Regards,

Christian

Jan Ciger

unread,
Apr 20, 2015, 4:47:37 AM4/20/15
to OpenSceneGraph Users
On Mon, Apr 20, 2015 at 10:34 AM, Christian Kehl <Christi...@uni.no> wrote:


Hi,

is there still anybody available who has an idea what could be wrong in this
instance ? The problem continues to persist and I don't know enough about
the android wrapping system to fix the problem myself. The problem has to be
in the static libraries, but where ?


It could be also a bug  in the Android port of OSG. OSG is designed to load plugins required to load the various data formats dynamically. Unfortunately, this doesn't really work well with Android because of the way Android applications are deployed, so OSG won't find its plugins (and models/textures/etc won't load).

Jordi Torres has implemented a workaround using static linking, that is what those plugin declaration macros were for. If you have compiled everything statically as described in the doc and it is still looking for .so files (DLLs in Windows parlance), then something seems borked in the osgDB plugin system, IMHO.

Do the osgAndroid examples shipped with OSG work for you? If those don't work neither, then something has changed in OSG and broke it since mid-2013 when I have last compiled the Android version (and when it was working).

J.





Jordi Torres

unread,
Apr 20, 2015, 4:58:39 AM4/20/15
to OpenSceneGraph Users
Hi Christian, Jan et al.

Sorry for not being too active.... Anyway, did you try to compile all with the last additions from Rafa Gaitán? Now it is possible to compile OSG for Android with dynamic libraries, take a look to http://www.openscenegraph.org/index.php/documentation/platform-specifics/android/178-building-openscenegraph-for-android-3-4 .
Is a must for you to use static libs? You can try the dynamic version, maybe it solves your problems.

Also we are using osgAndroid ( https://gitorious.org/osgandroid/pages/Home ) maybe it could be helpful. 

I'm building now OSG for Android to do some testing. 

I hope I can help a bit later. 


_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




--
Jordi Torres


Jordi Torres

unread,
Apr 20, 2015, 7:17:52 AM4/20/15
to OpenSceneGraph Users
Hi Christian, 

I just compiled OSG for Android and executed the example with the fresh build for GLES1 without major problems. 
What version of OSG are you running? Does the example shipped with OSG works for you? Are you compiling using the toolchain?

 
--
Jordi Torres


Christian Kehl

unread,
Apr 22, 2015, 7:29:56 AM4/22/15
to osg-...@lists.openscenegraph.org
Jordi Torres <jtorresfabra@...> writes:

>
>
> Hi Christian, 
> I just compiled OSG for Android and executed the example with the fresh
build for GLES1 without major problems. 
> What version of OSG are you running? Does the example shipped with OSG
works for you? Are you compiling using the toolchain?
>
>  
>
>
>
> 2015-04-20 10:58 GMT+02:00 Jordi Torres

<jtorresfabra-Re5J...@public.gmane.org>:


> Hi Christian, Jan et al.
> Sorry for not being too active.... Anyway, did you try to compile all with
the last additions from Rafa Gaitán? Now it is possible to compile OSG for
Android with dynamic libraries, take a look
to http://www.openscenegraph.org/index.php/documentation/platform-specifics/android/178-building-openscenegraph-for-android-3-4
.
> Is a must for you to use static libs? You can try the dynamic version,
maybe it solves your problems.
>
> Also we are using osgAndroid ( https://gitorious.org/osgandroid/pages/Home
) maybe it could be helpful. 
>
> I'm building now OSG for Android to do some testing. 
>
> I hope I can help a bit later. 
>
>
>
>

> Do the osgAndroid examples shipped with OSG work for you? If those don't
work neither, then something has changed in OSG and broke it since mid-2013
when I have last compiled the Android version (and when it was working).
>
> J.
>
>
>
>
>
>
>
>
>
> _______________________________________________

Hi to everybody,

it's comforting to see some activity going on. The last days, I was working
on another project, so please excuse my late reply too.

I am using OpenSceneGraph 3.0.1. The GLES1 and GLES2 example shipped with
android are the ones that break (not load data). It's not a must-have for me
to use static linking - if dynamic linking would work, it would be fine for
me too. At the moment, I just like to see some model on my android :-)

I will try out osgAndroid and the 3.0.4 build - let's hope it resolves the
issue. Jordi - which version of the NDK are you using ? I have the r10 NDK
installed. It may be good to know for tracking down the error.

News are about to be reported soon. Best Regards,

Christian

Jordi Torres

unread,
Apr 22, 2015, 7:51:43 AM4/22/15
to OpenSceneGraph Users
Hi, 
 
I am using OpenSceneGraph 3.0.1. The GLES1 and GLES2 example shipped with
android are the ones that break (not load data).

What instructions did you follow to compile? Did you use the toolchain? 
 
It's not a must-have for me
to use static linking - if dynamic linking would work, it would be fine for
me too. At the moment, I just like to see some model on my android :-)
I will try out osgAndroid and the 3.0.4 build - let's hope it resolves the
issue.

 
Jordi - which version of the NDK are you using ? I have the r10 NDK
installed. It may be good to know for tracking down the error.


I used ndk -r8e, I will try latest ndk when I have the time.
 
News are about to be reported soon. Best Regards,

Christian


_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Cheers. 

--
Jordi Torres


Jordi Torres

unread,
Apr 22, 2015, 10:29:52 AM4/22/15
to OpenSceneGraph Users
Hi Christian, 

I just compiled with ndk r10d, I used the gnustl_static from ($NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a

It works so far. 
--
Jordi Torres


Christian Kehl

unread,
Apr 22, 2015, 3:59:55 PM4/22/15
to osg-...@lists.openscenegraph.org
Christian Kehl <Christian.Kehl@...> writes:

>
> Jordi Torres <jtorresfabra <at> ...> writes:
>
> >
> >
> > Hi Christian, 
> > I just compiled OSG for Android and executed the example with the fresh
> build for GLES1 without major problems. 
> > What version of OSG are you running? Does the example shipped with OSG
> works for you? Are you compiling using the toolchain?
> >
> >  
> >
> >
> >
> > 2015-04-20 10:58 GMT+02:00 Jordi Torres

> <jtorresfabra@...>:


> > Hi Christian, Jan et al.
> > Sorry for not being too active.... Anyway, did you try to compile all with
> the last additions from Rafa Gaitán? Now it is possible to compile OSG for
> Android with dynamic libraries, take a look
>
to http://www.openscenegraph.org/index.php/documentation/platform-specifics/android/178-building-openscenegraph-for-android-3-4
> .
> > Is a must for you to use static libs? You can try the dynamic version,
> maybe it solves your problems.
> >
> > Also we are using osgAndroid ( https://gitorious.org/osgandroid/pages/Home
> ) maybe it could be helpful. 
> >
> > I'm building now OSG for Android to do some testing. 
> >
> > I hope I can help a bit later. 
> >
> >
> >
> >
> > Do the osgAndroid examples shipped with OSG work for you? If those don't
> work neither, then something has changed in OSG and broke it since mid-2013
> when I have last compiled the Android version (and when it was working).
> >
> > J.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > _______________________________________________
>
> Hi to everybody,
>
> it's comforting to see some activity going on. The last days, I was working
> on another project, so please excuse my late reply too.
>
> I am using OpenSceneGraph 3.0.1. The GLES1 and GLES2 example shipped with
> android are the ones that break (not load data). It's not a must-have for me
> to use static linking - if dynamic linking would work, it would be fine for
> me too. At the moment, I just like to see some model on my android
>

> I will try out osgAndroid and the 3.0.4 build - let's hope it resolves the
> issue. Jordi - which version of the NDK are you using ? I have the r10 NDK
> installed. It may be good to know for tracking down the error.
>
> News are about to be reported soon. Best Regards,
>
> Christian
>
> _______________________________________________
> osg-users mailing list

> osg-users <at> lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>

So, I downloaded the 3.3.7 developer version of OpenSceneGraph and ran the
cmake command as given in the link for "Building OpenSceneGraph 3.3.2-3.4.x
for Android" (sth. like it).

After a bit of hassle, it compiled fine.
I also put the 3rdParty folder inside the OSG root folder, but cmake reported
that CURL, Jpeg, Tiff etc. are missing - well, weird, but not urgent for now.
I use the svn version rc2, and compile with OPENGL_PROFILE "GLES2".

Then, I imported the GLES1/2 examples in Eclipse, modified the Android.mk so
to link to the installation folder (btw: still used static libs) and using
gnustl_static, ran ndk-build, and this is the output:

christian@PROMETHEUS:~/workspace/Android/osgViewerGLES1_337$

jni/OsgMainApp.cpp:101: error: undefined reference to
'osgViewer::View::addEventHandler(osgGA::EventHandler*)'
jni/OsgMainApp.cpp:102: error: undefined reference to
'osgViewer::View::addEventHandler(osgGA::EventHandler*)'
jni/OsgMainApp.cpp:103: error: undefined reference to
'osgViewer::View::addEventHandler(osgGA::EventHandler*)'
jni/OsgMainApp.cpp:104: error: undefined reference to
'osgViewer::View::addEventHandler(osgGA::EventHandler*)'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libosgNativeLib.so] Error 1

Hence, the static linker does not find the function
osgViewer::View::addEventHandler(...) in the library. This is the GLES1
example. I guess it is no surprise it doesn't find THAT (shouldn't it be
osgViewer::Viewer::addEventHandler ?!), rather the question is where this is
coded ? I assume there must be sth. going on in the DOTOSGWRAPPER of
osgViewer ...

The output for the osgViewerGLES2, configured and setup the same way, looks
as follows:

christian@PROMETHEUS:~/workspace/Android/osgViewer_337$

jni/OsgMainApp.cpp:113: error: undefined reference to
'osgViewer::View::addEventHandler(osgGA::EventHandler*)'
jni/OsgMainApp.cpp:114: error: undefined reference to
'osgViewer::View::addEventHandler(osgGA::EventHandler*)'
jni/OsgMainApp.cpp:115: error: undefined reference to
'osgViewer::View::addEventHandler(osgGA::EventHandler*)'
jni/OsgMainApp.cpp:116: error: undefined reference to
'osgViewer::View::addEventHandler(osgGA::EventHandler*)'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:555: error:
undefined reference to 'glColor4f'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:646: error:
undefined reference to 'glEnableClientState'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:651: error:
undefined reference to 'glVertexPointer'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:859: error:
undefined reference to 'glDisableClientState'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:1062: error:
undefined reference to 'glEnableClientState'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:1066: error:
undefined reference to 'glTexCoordPointer'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:828: error:
undefined reference to 'glEnableClientState'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:833: error:
undefined reference to 'glColorPointer'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:565: error:
undefined reference to 'glNormal3f'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:737: error:
undefined reference to 'glEnableClientState'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:742: error:
undefined reference to 'glNormalPointer'
/media/christian/DATA/OpenSceneGraph301/include/osg/State:859: error:
undefined reference to 'glDisableClientState'
/media/christian/DATA/OpenSceneGraph301/src/osgParticle/Particle.cpp:231:
error: undefined reference to 'glColor4f'
/media/christian/DATA/OpenSceneGraph301/src/osgParticle/Particle.cpp:232:
error: undefined reference to 'glPushMatrix'
/media/christian/DATA/OpenSceneGraph301/src/osgParticle/Particle.cpp:233:
error: undefined reference to 'glTranslatef'
/media/christian/DATA/OpenSceneGraph301/src/osgParticle/Particle.cpp:238:
error: undefined reference to 'glMultMatrixf'
/media/christian/DATA/OpenSceneGraph301/src/osgParticle/Particle.cpp:244:
error: undefined reference to 'glPopMatrix'
[...]
/media/christian/DATA/OpenSceneGraph301/src/osg/ArrayDispatchers.cpp:29:
error: undefined reference to 'glColor4f'
/media/christian/DATA/OpenSceneGraph301/src/osg/ArrayDispatchers.cpp:25:
error: undefined reference to 'glColor4ub'
/media/christian/DATA/OpenSceneGraph301/src/osg/ArrayDispatchers.cpp:34:
error: undefined reference to 'glNormal3f'
/media/christian/DATA/OpenSceneGraph301/src/osg/ArrayDispatchers.cpp:33:
error: undefined reference to 'glNormal3f'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libosgNativeLib.so] Error 1

Also there, it doesn't find the osgViewer::View::add..., but he also looks
for the GLES1 fixed functionality pipeline calls that surely don't exist.
The question for the is rather why the GLES2 example (I swear by god, it is
the GLES2 example), asks for GLES1 functions ?!

This is how far I got today. Any help would be highly appreciated. I also
append my cmake-line.

cmake .. -DOSG_BUILD_PLATFORM_ANDROID=ON -DDYNAMIC_OPENTHREADS=OFF
-DDYNAMIC_OPENSCENEGRAPH=OFF -DOSG_GL_DISPLAYLISTS_AVAILABLE=OFF
-DOSG_GL_MATRICES_AVAILABLE=OFF -DOSG_GL_VERTEX_FUNCS_AVAILABLE=OFF
-DOSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE=OFF
-DOSG_GL_FIXED_FUNCTION_AVAILABLE=OFF -DOSG_CPP_EXCEPTIONS_AVAILABLE=OFF


-DOSG_GL1_AVAILABLE=OFF -DOSG_GL2_AVAILABLE=OFF -DOSG_GL3_AVAILABLE=OFF
-DOSG_GLES1_AVAILABLE=OFF -DOSG_GLES2_AVAILABLE=ON

-DCMAKE_INSTALL_PREFIX=$HOME/android_install -DCMAKE_BUILD_TYPE=Release
-DCMAKE_TOOLCHAIN_FILE=/media/christian/DATA/OpenSceneGraph337
/PlatformSpecifics/Android/android.toolchain.cmake
-DOPENGL_PROFILE="GLES2"

Tomorrow, I go and try the osgAndroid repo out.

Best Regards already,

Rafa Gaitan

unread,
Apr 22, 2015, 6:18:00 PM4/22/15
to OpenSceneGraph Users
Hello Christian, 

Just to clarify a little bit the things:

- All the versions until 3.3.2 (I think that's the last one), should be compiled using the old system (generating the Android.mk files through cmake)

- Newer version must use the new Toolchain mechanism


Regarding the examples inside OSG, I don't know the current status, as far as I know Jordi made them work but I usually use osgAndroid. FYI I changed the repository of osgAndroid to github, seems that gitorious has been absorbed by gitlab, so I moved it out. The new url is: https://github.com/corsario/osgAndroid

Regarding the thirdparty dependencies with the new Toolchain, you are right, is something I forgot to add into cmake when I was cleaning it up for building for Android. I'll try to do it once I had some time.

On the other hand, you must build OSG either GLES1 or GLES2. If you build it against GLES2 then you need to add your own shaders to see something on screen, of course the example for GLES2 won't work if OSG was built with GLES1 and the GLES1 example won't show anything if OSG was compiled with GLES2, I apologize if this was already clarified :)

Best regards,
Rafa.

--
Rafael Gaitán Linares
CTO at Mirage Technologies S.L - http://www.mirage-tech.com

Christian Kehl

unread,
Apr 23, 2015, 5:48:05 AM4/23/15
to osg-...@lists.openscenegraph.org
Rafa Gaitan <rafa.gaitan@...> writes:

>
>
> Hello Christian, 
> Just to clarify a little bit the things:
>
> - All the versions until 3.3.2 (I think that's the last one), should be
compiled using the old system (generating the Android.mk files through cmake)
>
> - Newer version must use the new Toolchain mechanism
>
> Both methods are explained
here: http://www.openscenegraph.org/index.php/documentation/platform-specifics/android
>
>
> Regarding the examples inside OSG, I don't know the current status, as far
as I know Jordi made them work but I usually use osgAndroid. FYI I changed
the repository of osgAndroid to github, seems that gitorious has been
absorbed by gitlab, so I moved it out. The new url
is: https://github.com/corsario/osgAndroid
>
>
> Regarding the thirdparty dependencies with the new Toolchain, you are
right, is something I forgot to add into cmake when I was cleaning it up for
building for Android. I'll try to do it once I had some time.
>
> On the other hand, you must build OSG either GLES1 or GLES2. If you build
it against GLES2 then you need to add your own shaders to see something on
screen, of course the example for GLES2 won't work if OSG was built with
GLES1 and the GLES1 example won't show anything if OSG was compiled with
GLES2, I apologize if this was already clarified :)
>
> Best regards,
> Rafa.
>
>
>

Then how do I use the toolchain file for compiling examples that are
imported in Eclipse ? I don't fully understand the toolchain
mechanism further than basically compiling the libraries
(which went successfull so far).

Jordi Torres

unread,
Apr 23, 2015, 6:05:39 AM4/23/15
to OpenSceneGraph Users
Hi Christian
 
Then how do I use the toolchain file for compiling examples that are
imported in Eclipse ? I don't fully understand the toolchain
mechanism further than basically compiling the libraries
(which went successfull so far).


The toolchain stuff is only to compile the libraries. I will test from scratch, maybe I'm missing something, and my eclipse projects were created time ago. 

Cheers. 

--
Jordi Torres


Christian Kehl

unread,
Apr 23, 2015, 6:09:52 PM4/23/15
to osg-...@lists.openscenegraph.org
Christian Kehl <Christian.Kehl@...> writes:

>
> Rafa Gaitan <rafa.gaitan <at> ...> writes:
>

Hi Hi,

so, I downloaded osgAndroid, imported the projects into my Eclipse. I
like this more elegant way of jni-wrapping - comes close to what I've
seen in OpenCV when compiling it for mobile.

Then, I needed to rebuild the OpenSceneGraph 3.3.7, because
osgAndroid's README.md says "only working with GLES 1.1 builds".
okay, said - executed. I get the following errors already common
to me when building OSG GLES 1.1:

Linking CXX static library ../../../lib/libOpenThreads.a
[ 0%] Built target OpenThreads
[ 0%] Building CXX object src/osg/CMakeFiles/osg.dir/AlphaFunc.cpp.o
In file included from
/media/christian/DATA/OpenSceneGraph337/include/osg/GLDefines:25:0,
from
/media/christian/DATA/OpenSceneGraph337/include/osg/GLExtensions:18,
from
/media/christian/DATA/OpenSceneGraph337/include/osg/Shader:25,
from
/media/christian/DATA/OpenSceneGraph337/include/osg/StateAttribute:20,
from
/media/christian/DATA/OpenSceneGraph337/include/osg/AlphaFunc:17,
from
/media/christian/DATA/OpenSceneGraph337/src/osg/AlphaFunc.cpp:14:
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL: In function
'void glLoadMatrix(const float*)':
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:130:96: error:
'glLoadMatrixf' was not declared in this scope
inline void glLoadMatrix(const float* mat) {
glLoadMatrixf(static_cast<const GLfloat*>(mat)); }

^
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL: In function
'void glMultMatrix(const float*)':
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:131:96: error:
'glMultMatrixf' was not declared in this scope
inline void glMultMatrix(const float* mat) {
glMultMatrixf(static_cast<const GLfloat*>(mat)); }

^
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL: In function
'void glLoadMatrix(const double*)':
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:149:87: error:
ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
inline void glLoadMatrix(const double* mat) {
glLoadMatrixd(static_cast<const GLdouble*>(mat)); }

^
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:149:87: error:
expected '>' before 'GLdouble'
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:149:87: error:
expected '(' before 'GLdouble'
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:149:87: error:
'GLdouble' was not declared in this scope
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:149:96: error:
expected primary-expression before '>' token
inline void glLoadMatrix(const double* mat) {
glLoadMatrixd(static_cast<const GLdouble*>(mat)); }

^
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL: In function
'void glMultMatrix(const double*)':
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:150:87: error:
ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
inline void glMultMatrix(const double* mat) {
glMultMatrixd(static_cast<const GLdouble*>(mat)); }

^
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:150:87: error:
expected '>' before 'GLdouble'
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:150:87: error:
expected '(' before 'GLdouble'
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:150:87: error:
'GLdouble' was not declared in this scope
/media/christian/DATA/OpenSceneGraph337/build/include/osg/GL:150:96: error:
expected primary-expression before '>' token
inline void glMultMatrix(const double* mat) {
glMultMatrixd(static_cast<const GLdouble*>(mat)); }

^
/media/christian/DATA/OpenSceneGraph337/src/osg/AlphaFunc.cpp: In member
function 'virtual void osg::AlphaFunc::apply(osg::State&) const':
/media/christian/DATA/OpenSceneGraph337/src/osg/AlphaFunc.cpp:33:56: error:
'glAlphaFunc' was not declared in this scope
glAlphaFunc((GLenum)_comparisonFunc,_referenceValue);
^
src/osg/CMakeFiles/osg.dir/build.make:57: recipe for target
'src/osg/CMakeFiles/osg.dir/AlphaFunc.cpp.o' failed
make[2]: *** [src/osg/CMakeFiles/osg.dir/AlphaFunc.cpp.o] Error 1
CMakeFiles/Makefile2:249: recipe for target 'src/osg/CMakeFiles/osg.dir/all'
failed
make[1]: *** [src/osg/CMakeFiles/osg.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2

just switching the -DOPENGL_PROFILE flag to GLES2 did have no effect
on the error. So, I added the old flags to enforce GLES2 built.
successfully.

Then, I setup the paths of osgjni and android, as said in the
readme, started osgsimple (don't know - do I have to compile osgjni
and android ?!), and it broke ... any further suggestions ? Any idea
where the GLES1 error still may originate from ?

Jan Ciger

unread,
Apr 24, 2015, 4:00:42 AM4/24/15
to OpenSceneGraph Users

On Fri, Apr 24, 2015 at 12:09 AM, Christian Kehl <Christi...@uni.no> wrote:
just switching the -DOPENGL_PROFILE flag to GLES2 did have no effect
on the error. So, I added the old flags to enforce GLES2 built.
successfully.


Um, if you force the OSG build to be done using GLES2 I think the osgAndroid code will not work correctly (different way of handling shaders). That warning in the README is not there for fun.

The real question is why you are getting those compilation errors with GLES1. I have checked my old NDK r8d and I don't have those declarations (glDouble, the matrix functions using doubles) neither. That looks like an error in the OSG headers, because those things are not supported in OpenGL ES 1 so the code shouldn't be trying to compile them. Alternatively it should typedef GLfloat to GLdouble.

J.



Christian Kehl

unread,
Apr 24, 2015, 9:18:17 AM4/24/15
to osg-...@lists.openscenegraph.org
Jan Ciger <jan.ciger@...> writes:

>
>
>
> On Fri, Apr 24, 2015 at 12:09 AM, Christian Kehl <Christian.Kehl <at>
Hi Jan,

so, yeah, I added in line 35 of OpenSceneGraph/include/osg/GLDefines the line:

typedef GLfloat GLdouble;

Now GLES1 compiles. I get back to you with news after that is done.

Christian Kehl

unread,
Apr 24, 2015, 10:14:18 AM4/24/15
to osg-...@lists.openscenegraph.org
Christian Kehl <Christian.Kehl@...> writes:

>
> Hi Jan,
>
> so, yeah, I added in line 35 of OpenSceneGraph/include/osg/GLDefines the line:
>
> typedef GLfloat GLdouble;
>
> Now GLES1 compiles. I get back to you with news after that is done.
>
>

So, compilation is done. Now, the readme of osgAndroid says:
"... but the JNI part needs to be compiled using the Android NDK."
How should this be done ? If the old invocation of ndk-build via
the command line is deprecated, how else shall it be done ?

In OpenCV, one has the OpenCV manager to load a certain version, plus the
linked compilation of dependent sub-project - how is the building process in
Eclipse for the osgAndroid ?

Robert Osfield

unread,
Apr 24, 2015, 10:50:59 AM4/24/15
to OpenSceneGraph Users
Hi Chistian,

Could you post any modified files to osg-submissions so I can review
and merge the changes.

Cheers,
Robert.

Christian Kehl

unread,
Apr 25, 2015, 1:23:34 PM4/25/15
to osg-...@lists.openscenegraph.org
I posted the changes on the osg-submissions mailing list. I still have the problem of building the JNI libraries using Eclipse. Rafael, perhaps you can give me a hint on how to do that, or extend the readme on the project a bit further so this last step is clear on howto-do ?

Thanks and Cheers,
Christian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63532#63532

Rafa Gaitan

unread,
Apr 25, 2015, 3:30:23 PM4/25/15
to OpenSceneGraph Users
Hi,

It's been a while since I build an osgAndroid project, so maybe things have changed and now the readme is not longer valid.

The explained method for building JNI libraries within eclipse it's just a convenience way for not using the console each time you change something in the JNI part. 

As you can see in osgAndroid, there's a org.openscenegrap.android library which is the one doing the bridge between java and osg. That's the one that requires to be built using the ndk, so you just need to go with the console to that directory and execute ndk-build, of course you need to configure properly the OSG_SDK variable of the Android.mk of that project.

If everything is properly build I recommend you refresh eclipse projects and try the osgsimple example (remember to upload to the device the model in the correct path), osgAndroid is just a simple layer to help developing applications quickly on android.

Maybe reading on how to build NDK native projects in general will also help you understanding how works the osgAndroid project.

Regards,
Rafa.

Christian Kehl

unread,
Apr 25, 2015, 4:10:15 PM4/25/15
to osg-...@lists.openscenegraph.org
Hi,

Thank you for the clarification. I followed the example, which gave me this output:

christian@PROMETHEUS:/media/christian/DATA/osgAndroid/org.openscenegraph.android$ ${ANDROID_NDK}/ndk-build
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgViewer.cpp
jni/JNIosgViewer.cpp:23:28: fatal error: osg/observer_ptr: No such file or directory
#include <osg/observer_ptr>
^
compilation terminated.
make: *** [obj/local/armeabi/objs/jniosg-gles1/JNIosgViewer.o] Error 1

I had a look into the Android.mk file, which gave me the following insights:
1) the makefile statically searches for the osg plugins of version 3.3.3 - I hardcoded now 3.3.7 (which is the version I am using). Perhaps that could be done with some environment variable or automatic parsing ? I would involve a bit cmake code, I guess ...
2) the error above may come because "LOCAL_C_INCLUDES" is set, but "LOCAL_CPP_INCLUDES" is not. Because OSG is C++ and because that distinction matters for me with g++ in teh backend, I set the path.

After this minor adaptations, the compilation with the ndk actually progresses, but has problems when starting to link the libraries:

christian@PROMETHEUS:/media/christian/DATA/osgAndroid/org.openscenegraph.android$ ${ANDROID_NDK}/ndk-build
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgViewer.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosg.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgDB.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgUtil.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgGA.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIUtils.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= MultiViewNode.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= GLES2ShaderGenVisitor.cpp
[armeabi] SharedLibrary : libjniosg-gles1.so
/home/christian/Downloads/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: cannot find -losgdb_serializers_osgpresentation
/home/christian/Downloads/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lgnustl_static
/home/christian/android_install/lib/osgPlugins-3.3.7/libosgdb_ive.a(DataOutputStream.cpp.o):DataOutputStream.cpp:typeinfo for osg::Node const*: error: undefined reference to 'vtable for __cxxabiv1::__pointer_type_info'
/home/christian/Downloads/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
/home/christian/android_install/lib/libosgWidget.a(Input.cpp.o):Input.cpp:function osgWidget::Input::_calculateCursorOffsets(): error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/home/christian/android_install/lib/libosgWidget.a(Input.cpp.o):Input.cpp:function osgWidget::Input::_calculateCursorOffsets(): error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/home/christian/android_install/lib/libosgWidget.a(Widget.cpp.o):Widget.cpp:function osgWidget::Widget::Widget(osgWidget::Widget const&, osg::CopyOp const&): error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/home/christian/android_install/lib/libosgWidget.a(Window.cpp.o):Window.cpp:function osgWidget::Window::getParentList(std::list<osg::observer_ptr<osgWidget::Window>, std::allocator<osg::observer_ptr<osgWidget::Window> > >&) const: error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/home/christian/android_install/lib/libosgWidget.a(Window.cpp.o):Window.cpp:function osgWidget::Window::getEmbeddedList(std::list<osg::observer_ptr<osgWidget::Window>, std::allocator<osg::observer_ptr<osgWidget::Window> > >&) const: error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/home/christian/android_install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::merge<SortEvents>(std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >&, SortEvents): error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/christian/android_install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::merge<SortEvents>(std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >&, SortEvents): error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/christian/android_install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::sort<SortEvents>(SortEvents): error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/christian/android_install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::sort<SortEvents>(SortEvents): error: undefined reference to 'std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)'
/home/christian/android_install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::sort<SortEvents>(SortEvents): error: undefined reference to 'std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)'
/home/christian/android_install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::sort<SortEvents>(SortEvents): error: undefined reference to 'std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)'
/home/christian/android_install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function osgViewer::CompositeViewer::eventTraversal(): error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/christian/android_install/lib/libosgViewer.a(GraphicsWindow.cpp.o):GraphicsWindow.cpp:function std::list<osgViewer::View*, std::allocator<osgViewer::View*> >::sort(): error: undefined reference to 'std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)'
/home/christian/android_install/lib/libosgViewer.a(GraphicsWindow.cpp.o):GraphicsWindow.cpp:function osgViewer::GraphicsWindow::getViews(std::list<osgViewer::View*, std::allocator<osgViewer::View*> >&): error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/home/christian/android_install/lib/libosgViewer.a(View.cpp.o):View.cpp:function osgViewer::View::removeEventHandler(osgGA::EventHandler*): error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/home/christian/android_install/lib/libosgViewer.a(View.cpp.o):View.cpp:function std::list<osg::ref_ptr<osg::Camera>, std::allocator<osg::ref_ptr<osg::Camera> > >::operator=(std::list<osg::ref_ptr<osg::Camera>, std::allocator<osg::ref_ptr<osg::Camera> > > const&): error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/home/christian/android_install/lib/libosgText.a(Glyph.cpp.o):Glyph.cpp:function osgText::GlyphTexture::apply(osg::State&) const: error: undefined reference to 'glGenerateMipmap'
/home/christian/android_install/lib/libosgFX.a(AnisotropicLighting.cpp.o):AnisotropicLighting.cpp:function (anonymous namespace)::ViewMatrixExtractor::compare(osg::StateAttribute const&) const: error: undefined reference to 'std::type_info::before(std::type_info const&) const'
/home/christian/android_install/lib/libosgFX.a(BumpMapping.cpp.o):BumpMapping.cpp:function (anonymous namespace)::ViewMatrixExtractor::compare(osg::StateAttribute const&) const: error: undefined reference to 'std::type_info::before(std::type_info const&) const'
/home/christian/android_install/lib/libosgFX.a(SpecularHighlights.cpp.o):SpecularHighlights.cpp:function (anonymous namespace)::AutoTextureMatrix::compare(osg::StateAttribute const&) const: error: undefined reference to 'std::type_info::before(std::type_info const&) const'
/home/christian/android_install/lib/libosgFX.a(Validator.cpp.o):Validator.cpp:function osgFX::Validator::compare(osg::StateAttribute const&) const: error: undefined reference to 'std::type_info::before(std::type_info const&) const'
/home/christian/android_install/lib/libosg.a(Shader.cpp.o):Shader.cpp:function osg::Shader::PerContextShader::compileShader(osg::State&): error: undefined reference to 'glShaderBinary'
/home/christian/android_install/lib/libosg.a(Texture.cpp.o):Texture.cpp:function osg::Texture::TextureObjectManager::checkConsistency() const: error: undefined reference to 'typeinfo for char const*'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libjniosg-gles1.so] Error 1

I'll investigate that further by tomorrow.

I attached my new Android.mk, so you can have a look on the changes. it's the one from the "org.openscenegraph.android/jni" folder.

Thank you!

Cheers,
Christian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63534#63534




Attachments:
http://forum.openscenegraph.org//files/android_makefiletar_136.gz

Christian Kehl

unread,
Apr 26, 2015, 12:47:13 PM4/26/15
to osg-...@lists.openscenegraph.org
Hi,

I had a closer look to the errors and the Android.mk file. osgdb_serializers_osgpresentation doesn't exist in my build (perhaps missing in general - it wasn't in the 3.0.2 Android.mk file either, so that's new things that is added and missing in the build).

leaving the following errors:
christian@PROMETHEUS:/media/christian/DATA/osgAndroid/org.openscenegraph.android$ ${ANDROID_NDK}/ndk-build
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgViewer.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosg.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgDB.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgUtil.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgGA.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIUtils.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= MultiViewNode.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= GLES2ShaderGenVisitor.cpp
[armeabi] SharedLibrary : libjniosg-gles1.so
/home/christian/Downloads/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lgnustl_static
/home/christian/android-install/lib/osgPlugins-3.3.7/libosgdb_ive.a(DataOutputStream.cpp.o):DataOutputStream.cpp:typeinfo for osg::Node const*: error: undefined reference to 'vtable for __cxxabiv1::__pointer_type_info'
/home/christian/Downloads/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
/home/christian/android-install/lib/osgPlugins-3.3.7/libosgdb_serializers_osgparticle.a(RadialShooter.cpp.o):RadialShooter.cpp:function osgParticle::range<float>::get_random() const: error: undefined reference to 'rand'
/home/christian/android-install/lib/osgPlugins-3.3.7/libosgdb_serializers_osgparticle.a(RadialShooter.cpp.o):RadialShooter.cpp:function osgParticle::RadialShooter::shoot(osgParticle::Particle*) const: error: undefined reference to 'rand'
/home/christian/android-install/lib/osgPlugins-3.3.7/libosgdb_serializers_osgparticle.a(RandomRateCounter.cpp.o):RandomRateCounter.cpp:function osgParticle::RandomRateCounter::numParticlesToCreate(double) const: error: undefined reference to 'rand'
/home/christian/android-install/lib/osgPlugins-3.3.7/libosgdb_serializers_osgparticle.a(SectorPlacer.cpp.o):SectorPlacer.cpp:function osgParticle::SectorPlacer::place(osgParticle::Particle*) const: error: undefined reference to 'rand'
/home/christian/android-install/lib/libosgWidget.a(Input.cpp.o):Input.cpp:function osgWidget::Input::_calculateCursorOffsets(): error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/home/christian/android-install/lib/libosgWidget.a(Input.cpp.o):Input.cpp:function osgWidget::Input::_calculateCursorOffsets(): error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/home/christian/android-install/lib/libosgWidget.a(Widget.cpp.o):Widget.cpp:function osgWidget::Widget::Widget(osgWidget::Widget const&, osg::CopyOp const&): error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/home/christian/android-install/lib/libosgWidget.a(Window.cpp.o):Window.cpp:function osgWidget::Window::getParentList(std::list<osg::observer_ptr<osgWidget::Window>, std::allocator<osg::observer_ptr<osgWidget::Window> > >&) const: error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/home/christian/android-install/lib/libosgWidget.a(Window.cpp.o):Window.cpp:function osgWidget::Window::getEmbeddedList(std::list<osg::observer_ptr<osgWidget::Window>, std::allocator<osg::observer_ptr<osgWidget::Window> > >&) const: error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/home/christian/android-install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::merge<SortEvents>(std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >&, SortEvents): error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/christian/android-install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::merge<SortEvents>(std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >&, SortEvents): error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/christian/android-install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::sort<SortEvents>(SortEvents): error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/christian/android-install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::sort<SortEvents>(SortEvents): error: undefined reference to 'std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)'
/home/christian/android-install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::sort<SortEvents>(SortEvents): error: undefined reference to 'std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)'
/home/christian/android-install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function void std::list<osg::ref_ptr<osgGA::Event>, std::allocator<osg::ref_ptr<osgGA::Event> > >::sort<SortEvents>(SortEvents): error: undefined reference to 'std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)'
/home/christian/android-install/lib/libosgViewer.a(CompositeViewer.cpp.o):CompositeViewer.cpp:function osgViewer::CompositeViewer::eventTraversal(): error: undefined reference to 'std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
/home/christian/android-install/lib/libosgViewer.a(GraphicsWindow.cpp.o):GraphicsWindow.cpp:function std::list<osgViewer::View*, std::allocator<osgViewer::View*> >::sort(): error: undefined reference to 'std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)'
/home/christian/android-install/lib/libosgViewer.a(GraphicsWindow.cpp.o):GraphicsWindow.cpp:function osgViewer::GraphicsWindow::getViews(std::list<osgViewer::View*, std::allocator<osgViewer::View*> >&): error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/home/christian/android-install/lib/libosgViewer.a(View.cpp.o):View.cpp:function osgViewer::View::removeEventHandler(osgGA::EventHandler*): error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/home/christian/android-install/lib/libosgViewer.a(View.cpp.o):View.cpp:function std::list<osg::ref_ptr<osg::Camera>, std::allocator<osg::ref_ptr<osg::Camera> > >::operator=(std::list<osg::ref_ptr<osg::Camera>, std::allocator<osg::ref_ptr<osg::Camera> > > const&): error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/home/christian/android-install/lib/libosgText.a(Glyph.cpp.o):Glyph.cpp:function osgText::GlyphTexture::apply(osg::State&) const: error: undefined reference to 'glGenerateMipmap'
/home/christian/android-install/lib/libosgFX.a(AnisotropicLighting.cpp.o):AnisotropicLighting.cpp:function (anonymous namespace)::ViewMatrixExtractor::compare(osg::StateAttribute const&) const: error: undefined reference to 'std::type_info::before(std::type_info const&) const'
/home/christian/android-install/lib/libosgFX.a(BumpMapping.cpp.o):BumpMapping.cpp:function (anonymous namespace)::ViewMatrixExtractor::compare(osg::StateAttribute const&) const: error: undefined reference to 'std::type_info::before(std::type_info const&) const'
/home/christian/android-install/lib/libosgFX.a(SpecularHighlights.cpp.o):SpecularHighlights.cpp:function (anonymous namespace)::AutoTextureMatrix::compare(osg::StateAttribute const&) const: error: undefined reference to 'std::type_info::before(std::type_info const&) const'
/home/christian/android-install/lib/libosgFX.a(Validator.cpp.o):Validator.cpp:function osgFX::Validator::compare(osg::StateAttribute const&) const: error: undefined reference to 'std::type_info::before(std::type_info const&) const'
/home/christian/android-install/lib/libosgDB.a(FileUtils.cpp.o):FileUtils.cpp:function osgDB::fileType(std::string const&): error: undefined reference to 'stat64'
/home/christian/android-install/lib/libosgDB.a(FileUtils.cpp.o):FileUtils.cpp:function osgDB::makeDirectory(std::string const&): error: undefined reference to 'stat64'
/home/christian/android-install/lib/libosgDB.a(FileUtils.cpp.o):FileUtils.cpp:function osgDB::makeDirectory(std::string const&): error: undefined reference to 'stat64'
/home/christian/android-install/lib/libosg.a(Shader.cpp.o):Shader.cpp:function osg::Shader::PerContextShader::compileShader(osg::State&): error: undefined reference to 'glShaderBinary'
/home/christian/android-install/lib/libosg.a(Texture.cpp.o):Texture.cpp:function osg::Texture::TextureObjectManager::checkConsistency() const: error: undefined reference to 'typeinfo for char const*'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libjniosg-gles1.so] Error 1

most of them, if not all, can be tracked back to the very first error line: "cannot find -lgnustl_static". I tried a lot to add that path hardcoded - in the Android.mk file to the LOCAL_LDFLAGS (did not work) and to my commandline LD_LIBRARY_PATH - both did not work. Any idea how to circumvent this error ?

Thank you!

Cheers,
Christian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63535#63535

Rafa Gaitan

unread,
Apr 27, 2015, 2:07:22 AM4/27/15
to OpenSceneGraph Users
Hi,

Yes indeed is related to the STL. Recent versions of the NDK should have better support but I always find problems with that.

In the end I always copy the gnustl_static library from the android ndk to the OSG_SDK, but the android ndk should support it without that kind of workarounds.

Could you try add this to the Application.mk?

APP_CFLAGS += -fexceptions
APP_STL := gnustl_static

And remove the -lgnustl_static from the list of static libraries?

If still does not work then I recommend copy the library manually and continue with the current Android.mk.

Once I have more time I'll try a couple of solutions I found doing a quick search, but if you find the solution I'll be more than happy to apply the changes! :).

Regards,
Rafa.

Christian Kehl

unread,
Apr 27, 2015, 5:32:41 AM4/27/15
to osg-...@lists.openscenegraph.org
Hi,

the proposed change in the Application.mk did have no influence on the outcome, unfortunately. Hence, I reverted to the dirty trick of copying the libgnustl-shared.so and libgnustl_static.a to the OSG_LIB directory. That did get rid of the major body of errors, leaving just the following errors:

christian@PROMETHEUS:/media/christian/DATA/osgAndroid/org.openscenegraph.android$ ${ANDROID_NDK}/ndk-build
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgViewer.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosg.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgDB.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgUtil.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgGA.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIUtils.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= MultiViewNode.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= GLES2ShaderGenVisitor.cpp
[armeabi] SharedLibrary : libjniosg-gles1.so
/home/christian/android-install/lib/osgPlugins-3.3.7/libosgdb_serializers_osgparticle.a(RadialShooter.cpp.o):RadialShooter.cpp:function osgParticle::range<float>::get_random() const: error: undefined reference to 'rand'
/home/christian/android-install/lib/osgPlugins-3.3.7/libosgdb_serializers_osgparticle.a(RadialShooter.cpp.o):RadialShooter.cpp:function osgParticle::RadialShooter::shoot(osgParticle::Particle*) const: error: undefined reference to 'rand'
/home/christian/android-install/lib/osgPlugins-3.3.7/libosgdb_serializers_osgparticle.a(RandomRateCounter.cpp.o):RandomRateCounter.cpp:function osgParticle::RandomRateCounter::numParticlesToCreate(double) const: error: undefined reference to 'rand'
/home/christian/android-install/lib/osgPlugins-3.3.7/libosgdb_serializers_osgparticle.a(SectorPlacer.cpp.o):SectorPlacer.cpp:function osgParticle::SectorPlacer::place(osgParticle::Particle*) const: error: undefined reference to 'rand'
/home/christian/android-install/lib/libosgText.a(Glyph.cpp.o):Glyph.cpp:function osgText::GlyphTexture::apply(osg::State&) const: error: undefined reference to 'glGenerateMipmap'
/home/christian/android-install/lib/libosgDB.a(FileUtils.cpp.o):FileUtils.cpp:function osgDB::fileType(std::string const&): error: undefined reference to 'stat64'
/home/christian/android-install/lib/libosgDB.a(FileUtils.cpp.o):FileUtils.cpp:function osgDB::makeDirectory(std::string const&): error: undefined reference to 'stat64'
/home/christian/android-install/lib/libosgDB.a(FileUtils.cpp.o):FileUtils.cpp:function osgDB::makeDirectory(std::string const&): error: undefined reference to 'stat64'
/home/christian/android-install/lib/libosg.a(Shader.cpp.o):Shader.cpp:function osg::Shader::PerContextShader::compileShader(osg::State&): error: undefined reference to 'glShaderBinary'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libjniosg-gles1.so] Error 1

The first part of the errors is related to a missing rand() function. This is quite weird to me cause rand() is a core C function, so that should theoretically compile anywhere and everywhere. No clue why it misses that function.
Then, there are the two gl-related errors. The mipmap generation, I believe, is part of the glu-library, which is not referred to by the GLES library file (should that function be in the Android build in any case ?). The other one is the glShaderBinary, which could be a GLES1-GLES2 glitch, I assume.
The third category are the stat64 errors, which are related (I strongly believe) to some missing ifdefs for 32-bit - 64-bit compilation (as only the newest android models and the r10c NDK support 64-bit compile and run).

Any idea how to get rid of these last errors ?

Thank you!

Cheers,
Christian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63539#63539

Rafa Gaitan

unread,
Apr 27, 2015, 5:42:50 AM4/27/15
to OpenSceneGraph Users
Hi,

I have no clue on what could be happening, maybe trying a previous NDK version will work. Currently I'm not developing any project using osgAndroid, maybe others can give you more hints.

Rafa.

Christian Kehl

unread,
Apr 29, 2015, 8:22:39 AM4/29/15
to osg-...@lists.openscenegraph.org
Hi,

So, what I tried now is to revert to the old OpenSceneGraph. I was looking up in the internet for the rand() error on the android platform, where people say <cstdlib> needs to be explicitly included in the header that uses the function. The stat64 error is an ample ifdef construct in OpenSceneGraph/src/osgDB/FileUtils.cpp. I tried to add there the following (osg svn version 3.3.3)


#if defined(GL_VERSION_ES_CM_1_0) || defined(GL_VERSION_ES_CM_1_1) || defined(GL_VERSION_ES_2_0) || defined(GL_VERSION_ES_1_1) || defined(GL_VERSION_ES_1_0)
// if we are on android,we need to obscure the 64-bit pointer (needs to be adapted for android >=r10c
// due to 64 bit support)
#define stat64 stat
#endif

(line 93, after the switch for _DARWIN_FEATURE_64_BIT_INODE)

still, the work is unsuccessfull as I still get the same errors.

christian@PROMETHEUS:/media/christian/DATA/osgAndroid/org.openscenegraph.android$ ${ANDROID_NDK}/ndk-build
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgViewer.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosg.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgDB.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgUtil.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIosgGA.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= JNIUtils.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= MultiViewNode.cpp
[armeabi] Compile++ thumb: jniosg-gles1 <= GLES2ShaderGenVisitor.cpp
[armeabi] SharedLibrary : libjniosg-gles1.so
/home/christian/android-install/lib/osgPlugins-3.3.3/libosgdb_serializers_osgparticle.a(RadialShooter.cpp.o):RadialShooter.cpp:function osgParticle::range<float>::get_random() const: error: undefined reference to 'rand'
/home/christian/android-install/lib/osgPlugins-3.3.3/libosgdb_serializers_osgparticle.a(RadialShooter.cpp.o):RadialShooter.cpp:function osgParticle::RadialShooter::shoot(osgParticle::Particle*) const: error: undefined reference to 'rand'
/home/christian/android-install/lib/osgPlugins-3.3.3/libosgdb_serializers_osgparticle.a(RandomRateCounter.cpp.o):RandomRateCounter.cpp:function osgParticle::RandomRateCounter::numParticlesToCreate(double) const: error: undefined reference to 'rand'
/home/christian/android-install/lib/osgPlugins-3.3.3/libosgdb_serializers_osgparticle.a(SectorPlacer.cpp.o):SectorPlacer.cpp:function osgParticle::SectorPlacer::place(osgParticle::Particle*) const: error: undefined reference to 'rand'
/home/christian/android-install/lib/libosgDB.a(FileUtils.cpp.o):FileUtils.cpp:function osgDB::fileType(std::string const&): error: undefined reference to 'stat64'
/home/christian/android-install/lib/libosgDB.a(FileUtils.cpp.o):FileUtils.cpp:function osgDB::makeDirectory(std::string const&): error: undefined reference to 'stat64'
/home/christian/android-install/lib/libosgDB.a(FileUtils.cpp.o):FileUtils.cpp:function osgDB::makeDirectory(std::string const&): error: undefined reference to 'stat64'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libjniosg-gles1.so] Error 1


Thank you!

Cheers,
Christian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63567#63567

Rafa Gaitan

unread,
Apr 30, 2015, 2:05:27 AM4/30/15
to OpenSceneGraph Users
Hi Christian,

I've just uploaded a fix to osgAndroid to fix all the linkage problems with stl, I changed it to use the shared gnu stl library and inside the Java code I'm loading it before load the osg jni library.

I hope this fixes your problems, I've just made a quick test with osgsimple and it worked so far.

Regards,
Rafa.

Christian Kehl

unread,
Apr 30, 2015, 4:14:32 AM4/30/15
to osg-...@lists.openscenegraph.org
Hi,

Thanks Rafa, I'm giving it a try! Could you also quickly tell me which osg version you use ? The 3.3.3 from svn, or a different one ?

Cheers,
Christian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63577#63577

Rafa Gaitan

unread,
Apr 30, 2015, 5:17:33 AM4/30/15
to OpenSceneGraph Users

I updated from trunk this morning (3.3.8).

Rafa.

Christian Kehl

unread,
Apr 30, 2015, 12:56:57 PM4/30/15
to osg-...@lists.openscenegraph.org
Hi,
So, I needed to uncomment my submitted fix in GLDefines again, but with that, I actually made it through the compilation (yeaha).

Now, it generates the jar, I start osgSimple (I also created the osgAndroid folder on the phone and put the cessna in it) - buuut: the ap doesn't find the compiled library .a-files:

(eclipse report)
04-30 18:50:05.218: I/OpenSceneGraph-Android Library(11567): Successfully initialized
04-30 18:50:05.226: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.226: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.226: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.226: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.226: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.226: I/org.openscenegraph.osg.viewer.JNIViewer(11567): ShaderComposer::ShaderComposer() 0x70513830
04-30 18:50:05.226: I/org.openscenegraph.osg.viewer.JNIViewer(11567): ShaderComposer::ShaderComposer() 0x70513ba0
04-30 18:50:05.227: I/org.openscenegraph.osg.viewer.JNIViewer(11567): View::setSceneData() Reusing existing scene0x70526418
04-30 18:50:05.227: I/org.openscenegraph.osg.viewer.JNIViewer(11567): OSG Version:3.3.8
04-30 18:50:05.227: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.227: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.227: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.227: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.227: I/org.openscenegraph.osg.viewer.JNIViewer(11567): CullSettings::readEnvironmentalVariables()
04-30 18:50:05.227: I/org.openscenegraph.osg.viewer.JNIViewer(11567): ShaderComposer::ShaderComposer() 0x70513f60
04-30 18:50:05.227: I/org.openscenegraph.osg.viewer.JNIViewer(11567): ShaderComposer::ShaderComposer() 0x70529330
04-30 18:50:05.650: I/org.openscenegraph.osg.viewer.JNIViewer(11567): Warning: dynamic library 'osgPlugins-3.3.8/osgdb_osg.so' does not exist (or isn't readable):
04-30 18:50:05.650: I/org.openscenegraph.osg.viewer.JNIViewer(11567): dlopen failed: library "osgPlugins-3.3.8/osgdb_osg.so" not found
04-30 18:50:05.650: I/org.openscenegraph.osg.viewer.JNIViewer(11567): DynamicLibrary::failed loading "osgPlugins-3.3.8/osgdb_osg.so"
04-30 18:50:05.650: W/org.openscenegraph.osg.viewer.JNIViewer(11567): No data loaded
04-30 18:50:05.650: E/org.openscenegraph.osg.db.JNIosgDB(11567): Error loading scene
04-30 18:50:05.650: W/OSGActivity(11567): Attempt to invoke virtual method 'long org.openscenegraph.osg.core.Node.getNativePtr()' on a null object reference
04-30 18:50:05.658: D/OpenGLRenderer(11567): Render dirty regions requested: true
04-30 18:50:05.660: D/Atlas(11567): Validating map...
04-30 18:50:05.709: D/NvOsDebugPrintf(11567): NvRmPrivGetChipPlatform: Could not read platform information
04-30 18:50:05.709: D/NvOsDebugPrintf(11567): Expected on kernels without fuse support, using silicon
04-30 18:50:05.730: I/OpenGLRenderer(11567): Initialized EGL, version 1.4
04-30 18:50:05.781: D/OpenGLRenderer(11567): Enabling debug mode 0
04-30 18:50:05.930: V/RenderScript(11567): Application requested CPU execution
04-30 18:50:05.934: V/RenderScript(11567): 0x789cae00 Launching thread(s), CPUs 4

where do I have to copy the osgPlugins-3.3.8 folder to so to make that all work ?

I'm already quite happy it made it through the compilation - nice effort guys!

Cheers,
Christian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63589#63589

Rafa Gaitan

unread,
May 2, 2015, 2:47:11 AM5/2/15
to OpenSceneGraph Users
Hi,

If you built OSG in static, then the osgsimple sample should load properly the cessna model without worry about that message. OSG usually use the dynamic loading of the plugins and always emits that message even in static if the "dynamic" plugins is not found, anyway osgandroid preconfigures some of the required plugins in  the JNIosgDB.cpp filename using the macro USE_OSGPLUGIN.

If it's not working, maybe is something related to how you compiled OSG, or maybe your device has multiple external storages and the sample didn't found the model in the expected path.

My build configuration for osg was:

cmake .. -DANDROID_NDK=/Users/rgaitan/Projects/android/android-ndk-r10c/ -DCMAKE_TOOLCHAIN_FILE=../PlatformSpecifics/Android/android.toolchain.cmake           -DOPENGL_PROFILE="GLES1" -DDYNAMIC_OPENTHREADS=OFF -DDYNAMIC_OPENSCENEGRAPH=OFF          -DANDROID_NATIVE_API_LEVEL=15          -DANDROID_ABI=armeabi -DCMAKE_INSTALL_PREFIX=/Users/rgaitan/Projects/OSG/osg-trunk-android-static-gles1-sdk/

I hope you make it work soon :)

Regards,
Rafa.

Reply all
Reply to author
Forward
0 new messages