ios - g++ 与 iOS sysroot 和 xcode 8.1

标签 ios gcc g++ xcode8

使用 Xcode 8.0,我可以使用 sysroot 为 iOS 进行交叉编译:

/Applications/Xcode.app/Contents/Developer/usr/bin/g++ \
    --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk \
    -miphoneos-version-min=10.0 -arch armv7s -stdlib=libc++ -std=gnu++11 \
    helloworld.cpp

但是,在 Xcode 8.1 中,这种情况就会出现问题:

/Applications/Xcode.app/Contents/Developer/usr/bin/g++ \
    --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.1.sdk \
    -miphoneos-version-min=10.1 -arch armv7s -stdlib=libc++ -std=gnu++11 \
    helloworld.cpp
clang: warning: using sysroot for 'MacOSX' but targeting 'iPhone'
In file included from helloworld.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:215:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:90:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/wchar.h:70:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/_types.h:27:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:32:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:761:2: error: Unsupported architecture
#error Unsupported architecture

警告使用 sysroot for 'MacOSX' 但针对 'iPhone' 似乎表明 sysroot 参数被忽略(并且在错误中很明显,它的使用MacOSX10.12.sdk)。

这些论点有改变吗?如何正确指定sysroot?

最佳答案

在较新的 Xcode 中使用 -isysroot 而不是 --sysroot,并使用空格而不是等号。

关于ios - g++ 与 iOS sysroot 和 xcode 8.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41007556/

相关文章:

javascript - iOS 混合应用程序 - Google map API 错误 : RefererNotAllowedMapError

ios - 当新条目出现时,如何从右到左为标签内的文本设置动画?

ios - 授予 Facebook 应用程序查看我的点赞的权限是否允许该应用程序的所有其他用户也看到我的点赞?

iphone - 背景图像不适合屏幕

c - 段错误 SEGV_ACCERR - 对象的无效权限

linux - 如何使g++正确使用我自己的glibc构建的 header ?

c - 为什么我需要将 -1 的值转换为字符(为 AVR 微 Controller 编译时)

c++ - 编译扩展名为.c的CPP程序

c++ - g++ 排序函数警告

c++ - std::set 没有成员 emplace