我正在编译我的项目并看到链接问题
$ g++ -Wl,-z,now -Wl,-z,relro -pthread -Wl,-z,noexecstack -fPIC -Wl,--threads -Wl,--thread-count=4 -B../../third_party/gold -L. -Wl,-uIsHeapProfilerRunning,-uProfilerStart -Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi -Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl -Wl,-u_ZN15HeapLeakChecker12IgnoreObjectEPKv,-u_ZN15HeapLeakChecker14UnIgnoreObjectEPKv -Wl,--icf=none -Wl,-rpath=\$ORIGIN/lib/ -Wl,-rpath-link=lib/ -o cameo -Wl,--start-group obj/cameo/src/runtime/app/cameo.cameo_main.o obj/media/libmedia_sse.a ...(omitted many *.a here) -Wl,--end-group -lX11 -lXcursor -lXrandr -lXrender -lrt -ldl -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lXtst -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lXi -lXcomposite -lasound -lXdamage -lXext -lXfixes -lnss3 -lnssutil3 -lsmime3 -lplds4 -lplc4 -lnspr4 -lgconf-2 -lresolv -ldbus-1 -lcups -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lgnutls -lgcrypt -lz -lpthread -lm -lcrypt -L/lib/x86_64-linux-gnu -lexpat -ludev
/usr/include/c++/4.7/ext/new_allocator.h:110: error: undefined reference to 'std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >::basic_string(std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >&&)'
/usr/include/c++/4.7/bits/stl_construct.h:77: error: undefined reference to 'std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >::basic_string(std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >&&)'
error: ld returned 1 exit status
我的 gcc 库中的std::basic_string
符号如下:
$ find /usr -name libstdc++.a
/usr/lib/gcc/x86_64-linux-gnu/4.6/32/libstdc++.a
/usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a
/usr/lib/gcc/x86_64-linux-gnu/4.7/32/libstdc++.a
/usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.a
$ nm -C /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.a| grep basic_string | grep '&&'
nm: compatibility-debug_list-2.o: no symbols
nm: compatibility-list-2.o: no symbols
nm: compatibility-parallel_list-2.o: no symbols
0000000000000000 W std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::assign(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&&)
0000000000000000 W std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::operator=(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&&)
0000000000000000 W std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::basic_string(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&&)
0000000000000000 W std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::basic_string(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&&)
0000000000000000 n std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::basic_string(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&&)
0000000000000000 W std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string&&)
0000000000000000 W std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string&&)
0000000000000000 n std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string&&)
我怎样才能解决这个问题?
- 编辑 -
-std=gnu++11
从编译命令中删除后问题已解决。string16 的 Chromium 基础库似乎与 C++11 存在兼容性问题。