Do you use exactly this code?
There should be two underscore symbols.

#ifdef __cplusplus
extern "C" {
#endif

On 4 ноя, 13:47, zenoname <[email protected]> wrote:
> Hello,
>
> I'm trying to create a simple project with the Android NDK.
> I created a jni library which is calling a function from a shared C*
> library.
> I make it work with a C library but as soon as I try with a C++
> library it crashes (when calling the c++ function)
> As many posts I read I suspect a name mangling problem but whatever I
> tried it doesn't change the problem
>
> Here is a summary of what I've done : I created a jni library linking
> two simple libs (jnilib my jni interface with java, libtoto.so my c
> library, libtotocpp.so my cpp lib). The c* libs simply export a
> function returning a int. If I call GetNumber() form the C lib no
> problem. If I call the GetNumberCPP() from my C++ lib it crashes
>
> Here are the code and compilation stuffs.
>
> If anyone could tell me what's wrong that would be very very cool :)
>
> Thanks.
>
> - jnilib.c (arm-eabi-gcc -shared jnilib.c -o libjnilib.so  libtoto.so
> libtotocpp.so -nostdlib -Bdynamic)
> Here if I don't call GetNumberCPP() all works
>
>      #include "toto.h"
>      #include "toto.hpp"
>
>      #ifdef _cplusplus
>      extern "C"
>      {
>      #endif
>      jstring Java_amob_jnscapi_jnscapi_initserver  (JNIEnv* env,
> jobject thiz )
>      {
>              char version[50];
>              sprintf(version,"%d %d",GetNumberC(),GetNumberCPP());
>              return (*env)->NewStringUTF(env, version);
>      }
>      #ifdef _cplusplus
>      }
>
> - libtoto.so  (arm-eabi-gcc -shared toto.c -o libtoto.so -nostdlib -
> Bdynamic)
>
>         #include "toto.h"
>         int GetNumberC()
>         {
>             return 33;
>         }
>
> - libtotocpp.so (arm-eabi-g++ -shared toto.cpp -o libtotocpp.so -
> nostdlib -Bdynamic)
>
>      #include "toto.hpp"
>      #ifdef _cplusplus
>      extern "C"
>     {
>     #endif
>     int GetNumberCPP()
>     {
>           return 56;
>      }
>     #ifdef _cplusplus
>     }
>     #endif
>
> - In my java class I tried to load all libs ...
>
>                 System.loadLibrary("totocpp");
>                 System.loadLibrary("toto");
>                 System.loadLibrary("jnilib");

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to