Hi,

Below try/catch code can not pass build:
#include <stdio.h>

int main()
{
    try
    {
        printf("try statement\n");
        throw 1;
    }
    catch (...)
    {
       printf("catch exeption here\n");
    }
}

Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_ARM_MODE := arm

LOCAL_SRC_FILES := \
./test.cpp

LOCAL_CFLAGS += -fexceptions

LOCAL_LDFLAGS += -lstdc++

LOCAL_MODULE := test

include $(BUILD_EXECUTABLE)

How can we use try/catch on android? Any other flags needed for
Android.mk?

Below is compile error message:
target Executable: test (out/target/product/generic/obj/EXECUTABLES/
test_intermediates/LINKED/test)
out/target/product/generic/obj/EXECUTABLES/test_intermediates/./
test.o: In function `main':
/home/e12714/workspace/mydroid/try_catch/./test.cpp:9: undefined
reference to `__cxa_allocate_exception'
/home/e12714/workspace/mydroid/try_catch/./test.cpp:9: undefined
reference to `__cxa_throw'
/home/e12714/workspace/mydroid/try_catch/./test.cpp:11: undefined
reference to `__cxa_begin_catch'
/home/e12714/workspace/mydroid/try_catch/./test.cpp:11: undefined
reference to `__cxa_end_catch'
/home/e12714/workspace/mydroid/try_catch/./test.cpp:11: undefined
reference to `__cxa_end_catch'
/home/e12714/workspace/mydroid/try_catch/./test.cpp:11: undefined
reference to `__cxa_end_cleanup'
/home/e12714/workspace/mydroid/try_catch/./test.cpp:11: undefined
reference to `typeinfo for int'
out/target/product/generic/obj/EXECUTABLES/test_intermediates/./test.o:
(.ARM.extab.text.main+0x0): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [out/target/product/generic/obj/EXECUTABLES/
test_intermediates/LINKED/test] Error 1


BRs
lucky
2008/12/19

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

Reply via email to