2016-12-07 60 views
2

在Xcode 8.0我可以交叉編譯爲iOS:克++與iOS SYSROOT和xcode的8.1通過使用<code>sysroot</code>

/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 

的警告using sysroot for 'MacOSX' but targeting 'iPhone'似乎表明sysroot參數被忽略(並在錯誤中清楚表明其使用MacOSX10.12.sdk)。

這些論據是否改變了?我如何正確指定sysroot?

+0

我已經在蘋果開發者論壇上發佈了這個帖子:https://forums.developer.apple.com/thread/69102 – paleozogt

回答

1

由於Apple的gcc/g ++只是在clang/clang ++之上的墊片,我們可以直接使用clang嗎?

事實證明,工作原理:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ \ 
    --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 

蘋果的GCC/G ++似乎破獲了改變SYSROOT。不過,我們似乎可以使用gcc風格的參數--sysroot。方便!

奇怪的是,如果我嘗試使用前綴的叮噹聲,我必須使用-isysroot

clang++ \ 
    -isysroot /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 
0

使用-isysroot與新的Xcode,而不是--sysroot,並用空格代替等號。