在编译具有Qt依赖性的iOS的c ++(clang)项目并使用c ++ 11时编译错误“没有类型名为std :: u16string”

时间:2015-09-07 14:29:14

标签: qt c++11 clang

我正在尝试使用clang for iOS构建一个c ++库,具体取决于Qt。 我的编译命令是这样的:

xcrun --sdk iphoneos8.4 clang++ -Iinclude -I/Users/ls/projects/prompt-filesystem/src/../cpp_http -I/Users/ls/Qt/5.5/ios/include/QtNetwork -I/Users/ls/Qt/5.5/ios/include/QtCore -I/Users/ls/Qt/5.5/ios/include -std=c++11 -I/Users/ls/projects/haxe_libsodium/src/../dependencies/libsodium-ios/include -c -stdlib=libstdc++ -O2 -arch armv6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk -miphoneos-version-min=5.0 -Wno-parentheses -Wno-null-dereference -Wno-unused-value -Wno-bool-conversion -fno-stack-protector -DIPHONE=IPHONE -DIPHONEOS=IPHONEOS -DSTATIC_LINK -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=321 -I/usr/lib/haxe/lib/hxcpp/git/include -fexceptions -fstrict-aliasing -x c++ -Wno-invalid-offsetof /Users/ls/projects/prompt-filesystem/src/../cpp_http/QtHttp.cpp -oobj/iphoneos/e40135f5_QtHttp.o

DHX ...定义是因为这是一个hxcpp项目。现在我收到了这个构建错误:

In file included from /Users/ls/Qt/5.5/ios/include/QtNetwork/QNetworkAccessManager:1:
In file included from /Users/ls/Qt/5.5/ios/include/QtNetwork/qnetworkaccessmanager.h:37:
In file included from /Users/ls/Qt/5.5/ios/include/QtCore/QObject:1:
In file included from /Users/ls/Qt/5.5/ios/include/QtCore/qobject.h:41:
/Users/ls/Qt/5.5/ios/include/QtCore/qstring.h:739:55: error: no type named 'u16string' in namespace 'std'
static inline QString fromStdU16String(const std::u16string &s);

这与我使用c ++ 11的事实有关,但我想这样做是因为我需要在其他地方使用它。

我发现的唯一建议是,在包括Qt之前我应该​​包含“string”。但我这样做并没有帮助。

1 个答案:

答案 0 :(得分:2)

您的命令行选项-stdlib=libstdc++正在使用gcc-4.2&#39的标准库。这是一个早在C ++ 11之前产生的古老的std :: lib。 std::u16string是C ++ 11的新功能。

而不是-stdlib=libstdc++,请尝试-stdlib=libc++