开发者

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

开发者 https://www.devze.com 2023-03-10 02:55 出处:网络
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-androi

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?


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 :)


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

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

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

I took a long time to figure it out. Hope it helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消