std::map

638 views
Skip to first unread message

alex alex

unread,
Jun 22, 2011, 3:34:10 AM6/22/11
to android-ndk
Hi
I have a problem : when i add std::map in application it compiles fine
but in logcat i get signal 4 <SIGILL> code 1 <ILL_ILLOPC> , fault adr
83bd8804. I created a test application that works. When i add

map<char,int> first;

first['a']=10;

it compiles fine but i get the same thing in logcat . I'm using the
external dependencies form $(ANDROID_NDK_ROOT)/sources/cxx-stl/stlport/
stlport and the libraries $(ANDROID_NDK_ROOT)/cxx-stl/stlport/libs/
armeabi/libstlport_static.a and $(ANDROID_NDK_ROOT)/sources/cxx-stl/
gnu-libstdc++/libs/armeabi/libstdc++.a
from ndk r5c for a android 2.3 application

Can you help please!

David Turner

unread,
Jun 22, 2011, 4:33:33 AM6/22/11
to andro...@googlegroups.com
You can't mix and match C++ STL implementations. Select one and stick to it.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


alex alex

unread,
Jun 22, 2011, 5:20:50 AM6/22/11
to andro...@googlegroups.com
i tried it just with
$(ANDROID_NDK_ROOT)/sources/cxx-stl/stlport/libs/armeabi/libstlport_static.a
and it's still not working it only works if i comment the second line :

       map<char,int> first;

      // first['a']=10;


alex alex

unread,
Jun 22, 2011, 5:32:13 AM6/22/11
to andro...@googlegroups.com

David Turner

unread,
Jun 22, 2011, 7:06:26 AM6/22/11
to andro...@googlegroups.com
How do you build your code exactly? Are you using ndk-build and an Android.mk or not?

alex alex

unread,
Jun 22, 2011, 7:19:29 AM6/22/11
to andro...@googlegroups.com

I'm using ndk r5c, visual studio 2010 and ant build . I'm not using Android.mk.

David Turner

unread,
Jun 22, 2011, 7:25:01 AM6/22/11
to andro...@googlegroups.com
On Wed, Jun 22, 2011 at 1:19 PM, alex alex <alexdra...@gmail.com> wrote:

I'm using ndk r5c, visual studio 2010 and ant build . I'm not using Android.mk.

vs2010 has probably nothing to do with it.

How are you invoking the compiler? Did you try building a standalone toolchain (see docs/STANDALONE-TOOLCHAIN.html)

A standalone toolchain is probably the only sane way to generate machine code for Android if you're not using the NDK build system.
And it only supports GNU libstdc++, not stlport, btw. 

alex alex

unread,
Jun 22, 2011, 8:26:28 AM6/22/11
to andro...@googlegroups.com
I am using ndk build systems the only things i'm not using are cygwin and Android.mk .In stead of Android.mk i'm using MsBuild .

And i am wondering is anybody made an application that uses std::map (and of course if ti works ).

David Turner

unread,
Jun 22, 2011, 9:14:56 AM6/22/11
to andro...@googlegroups.com
On Wed, Jun 22, 2011 at 2:26 PM, alex alex <alexdra...@gmail.com> wrote:
I am using ndk build systems the only things i'm not using are cygwin and Android.mk .In stead of Android.mk i'm using MsBuild .


You are probably trying to call the toolchain binaries directly from MsBuild, this cannot work, really, unless you setup a standalone toolchain installation.
Read docs/STANDALONE-TOOLCHAIN.html for more information.
 
And i am wondering is anybody made an application that uses std::map (and of course if ti works ).

alex alex

unread,
Jun 23, 2011, 3:44:22 AM6/23/11
to andro...@googlegroups.com
Hi again
I compiled the sample san-angeles form $(ANDROID_NDK_ROOT)\samples and it worked fine on emulator and on my phone.
Then i added #include <map> form $(ANDROID_NDK_ROOT)\sources\cxx-stl\stlport\stlport and in the function  i added :



void
Java_com_example_SanAngeles_DemoRenderer_nativeInit( JNIEnv*  env )
{
   int importGLInit();
    appInit();
    gAppAlive    = 1;
    sDemoStopped = 0;
    sTimeOffsetInit = 0;
   
    //vector<int> first; (3,0);
   
    std::map<char,int> first;

    first['a']=10;

}

it compiles and it instals  on emulator and phone but at runtime siganl 4 SIGILL   ILL_ILLOPC .
It only works if i comment this :

   //first['a']=10

BTW vector works .Hope you can help me.



Reply all
Reply to author
Forward
0 new messages