Impossible to link to uchardet without -lstdc++ in cross environment
Submitted by Coacher
Assigned to Jehan Pagès @Jehan
Link to original bug (#102119)
Description
Hello.
I have successfully built uchardet in my cross environment (build is amd64, host is arm). Now I'm trying to link to it.
cat test.c
int main() { return 0; }
arm-unknown-linux-gnueabi-gcc test.c -luchardet
/usr/libexec/gcc/arm-unknown-linux-gnueabi/ld: warning: libstdc++.so.6, needed by /usr/arm-unknown-linux-gnueabi/usr/lib/libuchardet.so, not found (try using -rpath or -rpath-link)
/usr/arm-unknown-linux-gnueabi/usr/lib/libuchardet.so: undefined reference to __gxx_personality_v0@CXXABI_1.3' /usr/arm-unknown-linux-gnueabi/usr/lib/libuchardet.so: undefined reference to
vtable for __cxxabiv1::__si_class_type_info@CXXABI_1.3'
/usr/arm-unknown-linux-gnueabi/usr/lib/libuchardet.so: undefined reference to __cxa_pure_virtual@CXXABI_1.3' /usr/arm-unknown-linux-gnueabi/usr/lib/libuchardet.so: undefined reference to
vtable for __cxxabiv1::__class_type_info@CXXABI_1.3'
/usr/arm-unknown-linux-gnueabi/usr/lib/libuchardet.so: undefined reference to operator new(unsigned int)@GLIBCXX_3.4' /usr/arm-unknown-linux-gnueabi/usr/lib/libuchardet.so: undefined reference to
__cxa_end_cleanup@CXXABI_1.3'
/usr/arm-unknown-linux-gnueabi/usr/lib/libuchardet.so: undefined reference to `operator delete(void*)@GLIBCXX_3.4'
collect2: error: ld returned 1 exit status
arm-unknown-linux-gnueabi-gcc test.c -luchardet -lstdc++
As you can see without adding -lstdc++ I cannot link to uchardet. This problem affects real applications (e.g. mpv), which rely on linker flags provided by uchardet.pc. But uchardet.pc provides only -luchardet, while -lstdc++ is listed under Libs.private. Is there a sane way to deal with this problem?
Thank you.
P.S. gcc test.c -luchardet on native system works just fine.