57916

android NDK:compilation error:libstdc++:multiple definition of `std::bad_exception::~bad_exception()

Question:

While compiling the c++ code using android NDK I am getting the following error:

/System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o): In function `~exception': /tmp/ndk/src/build/../gcc/gcc-4.4.3/libstdc++-v3/libsupc++/eh_exception.cc:31: multiple definition of `std::exception::~exception()' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):/tmp/ndk-toolchain/ndk-prebuilt-31319/sources/cxx-stl/stlport/src/dll_main.cpp:65: first defined here /System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o): In function `~exception': /tmp/ndk/src/build/../gcc/gcc-4.4.3/libstdc++-v3/libsupc++/eh_exception.cc:31: multiple definition of `std::exception::~exception()' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):/tmp/ndk-toolchain/ndk-prebuilt-31319/sources/cxx-stl/stlport/src/dll_main.cpp:65: first defined here /System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o): In function `~bad_exception': /tmp/ndk/src/build/../gcc/gcc-4.4.3/libstdc++-v3/libsupc++/eh_exception.cc:33: multiple definition of `std::bad_exception::~bad_exception()' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):/tmp/ndk-toolchain/ndk-prebuilt-31319/sources/cxx-stl/stlport/src/dll_main.cpp:67: first defined here /System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o):(.data.rel.ro._ZTVSt13bad_exception+0x0): multiple definition of `vtable for std::bad_exception' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):(.data.rel.ro+0xf0): first defined here /System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o): In function `~bad_exception': /tmp/ndk/src/build/../gcc/gcc-4.4.3/libstdc++-v3/libsupc++/eh_exception.cc:33: multiple definition of `std::bad_exception::~bad_exception()' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):/tmp/ndk-toolchain/ndk-prebuilt-31319/sources/cxx-stl/stlport/src/dll_main.cpp:67: first defined here /System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o): In function `std::exception::what() const': /tmp/ndk/src/build/../gcc/gcc-4.4.3/libstdc++-v3/libsupc++/eh_exception.cc:46: multiple definition of `std::exception::what() const' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):/tmp/ndk-toolchain/ndk-prebuilt-31319/sources/cxx-stl/stlport/src/dll_main.cpp:68: first defined here /System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o): In function `std::bad_exception::what() const': /tmp/ndk/src/build/../gcc/gcc-4.4.3/libstdc++-v3/libsupc++/eh_exception.cc:52: multiple definition of `std::bad_exception::what() const' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):/tmp/ndk-toolchain/ndk-prebuilt-31319/sources/cxx-stl/stlport/src/dll_main.cpp:69: first defined here /System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o): In function `~exception': /tmp/ndk/src/build/../gcc/gcc-4.4.3/libstdc++-v3/libsupc++/eh_exception.cc:31: multiple definition of `std::exception::~exception()' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):/tmp/ndk-toolchain/ndk-prebuilt-31319/sources/cxx-stl/stlport/src/dll_main.cpp:65: first defined here /System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o): In function `~bad_exception': /tmp/ndk/src/build/../gcc/gcc-4.4.3/libstdc++-v3/libsupc++/eh_exception.cc:33: multiple definition of `std::bad_exception::~bad_exception()' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):/tmp/ndk-toolchain/ndk-prebuilt-31319/sources/cxx-stl/stlport/src/dll_main.cpp:67: first defined here /System/Library/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/libsupc++.a(eh_exception.o):(.data.rel.ro._ZTVSt9exception+0x0): multiple definition of `vtable for std::exception' /Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libstlport_static.a(dll_main.o):(.data.rel.ro+0x108): first defined here collect2: ld returned 1 exit status make: *** [/Users/user/Documents/copperworkspace/Pinecone/obj/local/armeabi/libGenCertificate.so] Error 1

I am using APP_STL := stlport_static in the application.mk Can you guys help?

Answer1:

I finally found the answer by going through the CPLUSPLUS-SUPPORT.html. There was a multiple definition of the exception class functions in stdc++ and stlport libraries. So instead of adding stlport library statically, I added it dynamically by changing APP_STL in the Application.mk as: APP_STL := stlport_shared

And it solved the problem :)

Answer2:

<em>I was having the same problem, but the Nishant Soni's solution wasn't enough.</em>

After assuring myself that there were no duplicate files or multiple declarations,what I did to <strong>solve</strong> was executing a Android Studio's <strong>Clean</strong> command. (<strong>Build -> Clean Project</strong>).

What caused the problem was <em>maybe</em> that I changed my project's path (moved the folder)

<em>I took a long time to figure it out. Hope it helps!</em>

Recommend

  • Android NDK debugging: device can't be opened
  • “dlopen failed: is 32-bit instead of 64-bit” in tests only
  • Can't compile/assemble MRC and MCR coprocessor instructions on iPhone?
  • mobile-chrome-apps using cordova plugin
  • Include label attribute into xtable header
  • Invoke another constructor in the same class
  • c++ create an array with string::size
  • Can we overload malloc()?
  • How should I add a stationary progress bar to a C++ program that produces terminal output (in Linux)
  • Create ranking for vector of double
  • C++ how to get substring after get position of its index
  • Need help to stop program terminating without users consent
  • Cast boost::array for function with argument (const float (&arr)[12])
  • What's the essential difference between these two variadic functions?
  • Get the App path without the app name at the end of the app
  • C++ and JS RegEx equivalent of \\p{L}
  • C++ Coin flip program error
  • Can't see some objects' internals in Qt Creator's Locals and Expressions debug window
  • Partial specialization of a class template in derived class affects base class
  • Jenkins: could not create Android emulator failed to parse AVD config file
  • Debugging Android native application using ndk-gdb
  • Wrap C++ function using Boost Reflect or another C++ reflection library
  • runtime-check whether an instance (Base*) override a parent function (Base::f())
  • “mvn clean generate-source” could not resolve dependencies
  • Building Qt project for C++11 standard
  • C++ friend class std::vector
  • How to load gif image while ajax content is loading and javascript [duplicate]
  • Error in installing package: fatal error: stdlib.h: no such file or directory
  • Pycharm: Marking a folder as 'sources root' is not recursive for subfolders
  • Using a canvas object in a thread to do simple animations - Java
  • ADO and msqli connections very slow
  • MonoTouch: How to download pdf incrementally as indicated in the Apple slides “Building Newsstand Ap
  • Installed module is empty
  • PHP buffered output depending on server setting?
  • Cassandra Data Model
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs