multiple definition of `std::exception::~exception()'

597 views
Skip to first unread message
Message has been deleted
Message has been deleted

Ó. Egilsson

unread,
Feb 7, 2011, 6:32:20 AM2/7/11
to android-ndk
I'm getting weird error when trying to use STL's vector:

/tmp/ndk/src/build/../gcc/gcc-4.4.3/libstdc++-v3/libsupc++/
eh_exception.cc:31:
multiple definition of `std::exception::~exception()'

Basically:

#include <vector>
std::vector<You> balls;
balls.push_back(You());

Any ideas ?

(Have the gut feeling it's my rusty C++'s knowledge to blame)

*** ANDROID.MK ***
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := jnitest
LOCAL_SRC_FILES := Simulation.cpp You.cpp

LOCAL_LDLIBS := -llog

include $(BUILD_SHARED_LIBRARY)

*** Application.mk ***
APP_STL := stlport_static
APP_CPPFLAGS += -fexceptions
# I do need the exeptions in other places

*** Simulation.cpp ***
#include "Simulation.h"

Simulation::Simulation() { }
Simulation::~Simulation() { }

void Simulation::addBalls() {
balls.push_back(You());
}

*** You.cpp ***
/*
* You.cpp
*
* Created on: Feb 4, 2011
* Author: olafure
*/

#include "You.h"

*** Simulation.h ***
#ifndef SIMULATION_H_
#define SIMULATION_H_

#include <vector>
#include "You.h"

class Simulation {
public:
Simulation();
virtual ~Simulation();
std::vector<You> balls;

private:
void addBalls();

};

#endif /* SIMULATION_H_ */

*** You.h ***
#ifndef YOU_H_
#define YOU_H_

class You {
public:
You() { }
virtual ~You();

};

#endif /* YOU_H_ */
*** Simulation.cpp ***
#include "Simulation.h"

Simulation::Simulation() { }
Simulation::~Simulation() { }

void Simulation::addBalls() {
balls.push_back(You());

}

*** You.cpp ***
#include "You.h"

*** Simulation.h ***
#ifndef SIMULATION_H_
#define SIMULATION_H_

#include <vector>
#include "You.h"

class Simulation {
public:
Simulation();
virtual ~Simulation();
std::vector<You> balls;

private:
void addBalls();

};

#endif /* SIMULATION_H_ */

*** You.h ***
#ifndef YOU_H_
#define YOU_H_

class You {
public:
You() { }
virtual ~You();

};

#endif /* YOU_H_ */

alan

unread,
Feb 7, 2011, 8:01:57 AM2/7/11
to andro...@googlegroups.com
execeptions are only supported when using stlport. from the docs:
WARNING: IMPORTANT CAVEAT

AT THE MOMENT, OUR STLPORT IMPLEMENTATION DOES NOT SUPPORT EXCEPTIONS
AND RTTI. PLEASE BE SURE TO NOT USE -fexceptions OR -frtti IN ALL
MODULES THAT USE IT.

IF YOU NEED THESE, PLEASE USE "gnustl_static".

İsmail Dönmez

unread,
Feb 7, 2011, 8:02:54 AM2/7/11
to andro...@googlegroups.com
You mean only supported with "gnustl_static"


--
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.

Ó. Egilsson

unread,
Feb 7, 2011, 8:05:50 AM2/7/11
to android-ndk
With gnustl_static I get different errors ...

Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile++ thumb : jnitest <= Simulation.cpp
Compile++ thumb : jnitest <= You.cpp
SharedLibrary : libjnitest.so
/local/data/android/projects/TheTest/obj/local/armeabi/objs-debug/
jnitest/Simulation.o: In function `You':
/local/data/android/projects/TheTest/jni/You.h:6: undefined reference
to `vtable for You'
/local/data/android/projects/TheTest/obj/local/armeabi/objs-debug/
jnitest/Simulation.o: In function `Simulation::addBalls()':
/local/data/android/projects/TheTest/jni/Simulation.cpp:8: undefined
reference to `You::~You()'
/local/data/android/projects/TheTest/jni/Simulation.cpp:8: undefined
reference to `You::~You()'
/local/data/android/projects/TheTest/obj/local/armeabi/objs-debug/
jnitest/Simulation.o: In function `You':
/local/data/android/projects/TheTest/jni/You.h:4: undefined reference
to `vtable for You'
/local/data/android/projects/TheTest/obj/local/armeabi/objs-debug/
jnitest/Simulation.o: In function `std::vector<You,
std::allocator<You>
>::_M_insert_aux(__gnu_cxx::__normal_iterator<You*, std::vector<You,
std::allocator<You> > >, You const&)':
/local/software/android/ndk/sources/cxx-stl/gnu-libstdc++/include/bits/
vector.tcc:312: undefined reference to `You::~You()'
/local/software/android/ndk/sources/cxx-stl/gnu-libstdc++/include/bits/
vector.tcc:312: undefined reference to `You::~You()'
/local/data/android/projects/TheTest/obj/local/armeabi/objs-debug/
jnitest/Simulation.o: In function `std::vector<You,
std::allocator<You> >::_M_check_len(unsigned int, char const*) const':
/local/software/android/ndk/sources/cxx-stl/gnu-libstdc++/include/bits/
stl_vector.h:1153: undefined reference to
`std::__throw_length_error(char const*)'
/local/data/android/projects/TheTest/obj/local/armeabi/objs-debug/
jnitest/Simulation.o: In function
`__gnu_cxx::new_allocator<You>::allocate(unsigned int, void const*)':
/local/software/android/ndk/sources/cxx-stl/gnu-libstdc++/include/ext/
new_allocator.h:87: undefined reference to `std::__throw_bad_alloc()'
collect2: ld returned 1 exit status
make: *** [/local/data/android/projects/TheTest/obj/local/armeabi/
libjnitest.so] Error 1



On Feb 7, 1:02 pm, İsmail Dönmez <ism...@namtrac.org> wrote:
> You mean only supported with "gnustl_static"
>

İsmail Dönmez

unread,
Feb 7, 2011, 8:06:25 AM2/7/11
to andro...@googlegroups.com
Make sure you do a clean build.

Ó. Egilsson

unread,
Feb 7, 2011, 8:08:34 AM2/7/11
to android-ndk
Cleaned eclipse project and ran
ndk-build clean
still the same errors.

On Feb 7, 1:06 pm, İsmail Dönmez <ism...@namtrac.org> wrote:
> Make sure you do a clean build.
>

Ó. Egilsson

unread,
Feb 7, 2011, 8:24:07 AM2/7/11
to android-ndk
Thanks a bunch for slapping me with the documentation :)

Those errors fixed by defining constructor and destructor for You.
This compiles fine, so my real project has some other errors...
Using gnustl with it produces:
undefined reference to `std::__throw_length_error(char const*)'

Better make an better example to reproduce that error ...

Ó. Egilsson

unread,
Feb 7, 2011, 8:29:33 AM2/7/11
to android-ndk
Real project compiled fine after a wash with "ndk-build clean" like
suggested.
Better catch up on some sleep.

Thanks a lot!
Reply all
Reply to author
Forward
0 new messages