2009-10-26 90 views
1

我試圖編譯iPhone模擬器一些代碼,但我得到這個錯誤:爲iPhone模擬器編譯錯誤

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -O3 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -Os -O3 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -Os -x objective-c -I../../include -c version.c  
    In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:29, 
        from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:14, 
        from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:80, 
        from version.c:11: 
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:166: error: expected declaration specifiers or ‘...’ before ‘SecPadding’ 
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:196: error: expected declaration specifiers or ‘...’ before ‘SecPadding’ 
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:228: error: expected declaration specifiers or ‘...’ before ‘SecPadding’ 
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:257: error: expected declaration specifiers or ‘...’ before ‘SecPadding’ 
    make: *** [version.o] Error 1 

但是,如果我編譯實際的iphone,它工作正常:

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -O3 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -arch armv6 -Os -O3 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -arch armv6 -Os -x objective-c -I../../include -c version.c  

發生此問題與文件一樣簡單只是包括Foundation.h沒有其他代碼:

#import <Foundation/Foundation.h> 

關於這是關於什麼的想法?奇怪的是,我預計這會失敗的iPhone和模擬器。

編輯:fyi,我沒有使用XCode。這是一個使用Makefiles的大型多平臺項目。您在上面看到的命令是從Makefile中發出的。

+0

不是說它在這個例子中有幫助,但是你知道你可以通過命令行來創建一個XCode項目嗎?請參閱http://stackoverflow.com/questions/377992/building-xcode-projects-from-the-command-line – 2009-10-27 17:24:21

+0

感謝您的提示。但是,在這種情況下它沒有用,因爲我們只是使用Makefiles。 – paleozogt 2009-10-27 17:25:50

回答

4

我看到了同樣的事情。解決方法是添加-miphoneos-version-min = 3.0編譯器指令。

+0

經過一些考慮(並試驗)之後,我認爲這是更好的答案。 -miphoneos-version-min似乎是-mmacosx-version-min的iphone等價物。 – paleozogt 2010-03-25 19:32:55

+0

順便說一句,你是什麼意思「添加-miphoneos-version-min = 3.0編譯器指令」?是否在項目設置中添加了新的其他鏈接器標記? – Artem 2012-02-24 14:38:51

0

你確定你的設置在兩個項目之間是相同的嗎?我敢打賭你不小心改變了一些模擬器設置。

+0

它只是一個項目。我沒有使用XCode。 – paleozogt 2009-10-27 16:43:19

0

右鍵單擊該框架,然後單擊獲取信息。查看「信息」對話框中的路徑。它應該很短,如「System/Library/Frameworks /」

如果不是,請使用選擇按鈕在當前SDK文件夾下查找框架。

此外,請確保在路徑下方看到選中「相對於當前SDK」選項。

+0

右鍵單擊框架...在Finder中?也許你的意思是在XCode。我不使用XCode。 – paleozogt 2009-10-27 16:43:56

0

當您將框架添加到您的項目中時,是否在複選框被設置爲YES時詢問您是否要將框架複製到項目文件夾中。如果是這樣,複選框應該設置爲NO。

請問,如果你創建一個新的項目,並嘗試在沒有添加任何運行,這也發生,因爲它可能是你不小心改變了編譯標誌在該項目

+0

我沒有使用XCode。 – paleozogt 2009-10-27 16:42:43

1

如果你使用SDK的問題只發生3.0與iPhone模擬器。使用SDK 2.0(使用gcc 4.0)將被編譯。這似乎是XCode默認使用的。

這很奇怪,這個問題只針對模擬器而不針對iphone本身。另外奇怪的是gcc4.2不能用模擬器sdk 2.0進行編譯 - 你必須使用gcc4.0。

對於好奇,我寫了演示該問題一個makefile:

IPHONE_GCC_VER = 4.0 
IPHONE_SDK_VER = 3.0 
IPHONE_DEV_PATH = /Developer/Platforms/iPhoneOS.platform/Developer 
IPHONE_SDK  = $(IPHONE_DEV_PATH)/SDKs/iPhoneOS$(IPHONE_SDK_VER).sdk 
IPHONE_GCC  = $(IPHONE_DEV_PATH)/usr/bin/gcc-$(IPHONE_GCC_VER) 

SIMULATOR_GCC_VER = 4.0 
SIMULATOR_SDK_VER = 2.0 
SIMULATOR_DEV_PATH= /Developer/Platforms/iPhoneSimulator.platform/Developer 
SIMULATOR_SDK  = $(SIMULATOR_DEV_PATH)/SDKs/iPhoneSimulator$(SIMULATOR_SDK_VER).sdk 
SIMULATOR_GCC  = $(SIMULATOR_DEV_PATH)/usr/bin/gcc-$(SIMULATOR_GCC_VER) 

TEST_FILE=/tmp/test.m 

all: info make-test-file 
    $(IPHONE_GCC) -isysroot $(IPHONE_SDK) -arch armv6 -c $(TEST_FILE) 
    $(SIMULATOR_GCC) -isysroot $(SIMULATOR_SDK) -arch i386 -c $(TEST_FILE) 

info: 
    @echo "iphone gcc : $(IPHONE_GCC_VER)" 
    @echo "iphone sdk : $(IPHONE_SDK_VER)" 
    @echo "simulator gcc: $(SIMULATOR_GCC_VER)" 
    @echo "simulator sdk: $(SIMULATOR_SDK_VER)" 
    @echo "" 

make-test-file: 
    echo "#import <Foundation/Foundation.h>" > $(TEST_FILE) 

的默認值是工作的,但是你可以重寫他們在命令行。例如:

$ make -f Makefile.iphone-error-demo SIMULATOR_SDK_VER=3.0 SIMULATOR_GCC_VER=4.0 
iphone gcc : 4.0 
iphone sdk : 3.0 
simulator gcc: 4.0 
simulator sdk: 3.0 

echo "#import <Foundation/Foundation.h>" > /tmp/test.m 
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk  -arch armv6 -c /tmp/test.m 
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -arch i386 -c /tmp/test.m 
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:29, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:14, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:80, 
       from /tmp/test.m:1: 
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:166: error: syntax error before ÔSecPaddingÕ 
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:196: error: syntax error before ÔSecPaddingÕ 
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:228: error: syntax error before ÔSecPaddingÕ 
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:257: error: syntax error before ÔSecPaddingÕ 
make: *** [all] Error 1 

$ make -f Makefile.iphone-error-demo SIMULATOR_SDK_VER=2.0 SIMULATOR_GCC_VER=4.2 
iphone gcc : 4.0 
iphone sdk : 3.0 
simulator gcc: 4.2 
simulator sdk: 2.0 

echo "#import <Foundation/Foundation.h>" > /tmp/test.m 
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk  -arch armv6 -c /tmp/test.m 
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk -arch i386 -c /tmp/test.m 
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:12, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6, 
       from /tmp/test.m:1: 
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory 
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6, 
       from /tmp/test.m:1: 
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/include/float.h:8:24: error: float.h: No such file or directory 
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/DriverServices.h:32, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:125, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:2, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:8, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:107, 
       from /tmp/test.m:1: 
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:29:23: error: xmmintrin.h: No such file or directory 
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/DriverServices.h:32, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:125, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:2, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:8, 
       from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:107, 
       from /tmp/test.m:1: 
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:216: error: expected specifier-qualifier-list before Ô__m128Õ 
make: *** [all] Error 1 
+0

不完全是問題的答案。但我在這裏看到的是同樣的東西。 – tcurdt 2009-12-30 21:30:02

0

這應該是固定的,加入這個編譯器選項:

-D__IPHONE_OS_VERSION_MIN_REQUIRED=30000 
+0

雖然這看起來不能解決SDK的v2問題,但它*可以*修復v3的問題。活泉! – paleozogt 2010-02-03 22:23:31

+0

經過一些考慮(並試驗)後,我認爲「-miphoneos-version-min」是更好的答案... – paleozogt 2010-03-25 19:33:28

0

將項目從sdk 3.2更改爲4.1時遇到此問題。原來的解決方案是在我的項目的構建設置中將iOS部署目標2.0更改爲3.0

右鍵單擊xcode中的項目(如果您使用的話),構建窗格,iOS部署目標 - > 3.0。

+1

正如我在問題中所說(以及對大多數答案的迴應),*我沒有使用Xcode * – paleozogt 2010-09-13 15:22:41