为具有 Qt 依赖项并使用 c++11 的 iOS 编译 c++(clang) 项目时编译错误 "no type named std::u16string"
Compile error "no type named std::u16string" when compiling c++(clang) project for iOS with Qt dependencies and using c++11
我正在尝试使用 clang 为 iOS 构建一个依赖于 Qt 的 c++ 库。
我的编译命令是这样的:
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"。但我正在这样做,但没有帮助。
您的命令行选项 -stdlib=libstdc++
正在使用 gcc-4.2 的标准库。这是在 C++11 之前很久就产生的一个古老的 std::lib。 std::u16string
是 C++11 的新增内容。
而不是 -stdlib=libstdc++
,试试 -stdlib=libc++
。
我正在尝试使用 clang 为 iOS 构建一个依赖于 Qt 的 c++ 库。 我的编译命令是这样的:
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"。但我正在这样做,但没有帮助。
您的命令行选项 -stdlib=libstdc++
正在使用 gcc-4.2 的标准库。这是在 C++11 之前很久就产生的一个古老的 std::lib。 std::u16string
是 C++11 的新增内容。
而不是 -stdlib=libstdc++
,试试 -stdlib=libc++
。