编译带有Qt依赖项的iOS版c++(clang)项目并使用c ++ 11时编译错误"no type named std::u16string"



我试图建立一个c++库依赖于Qt使用clang为iOS。我的编译命令是:

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.但我这样做,它没有帮助。

您的命令行选项-stdlib=libstdc++正在使用gcc-4.2的标准库。这是一个古老的std::lib,早在c++ 11之前就产生了。std::u16string在c++ 11中是新的。

-stdlib=libc++代替-stdlib=libstdc++

最新更新