Compilation error for iphone simulator

I am trying to compile the code for the iphone simulator but I am getting this error:

    /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

      

However, if I compile for a real iphone it works fine:

    /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      

      

This problem occurs with the file as easily as with Foundation.h without any other code:

#import <Foundation/Foundation.h>

      

Any ideas on what this means? It's weird that I expect this to fail for both iphone and simulator.

EDIT: fyi, I am not using XCode. It is a large multi-platform project using a Makefile. The commands you see above were taken from the Makefile.

+2


source to share


7 replies


I've seen the same thing. The fix is ​​to add the -miphoneos-version-min = 3.0 directive.



+4


source


The problem only occurs when using SDK 3.0 with iphone simulator. Using SDK 2.0 (with gcc 4.0) will compile. It looks like this is what Xcode uses by default.

It is very strange that this problem is only for the simulator and not for the iphone itself. It's also strange that gcc4.2 won't compile with the sdk 2.0 simulator - you have to use gcc4.0.

For the curious, I wrote a makefile that demonstrates the problem:

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)

      



The defaults are the ones that work, but you can override them on the command line. For example:

$ 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

      

or

$ 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

      

+1


source


Are you sure your settings are the same between the two projects? I would bet that you accidentally changed some of the simulator settings.

0


source


Right-click the frame and click Get Info. Take a look at the path in the Info dialog box. It should be short, like "System / Library / Frameworks /"

If this is not the case, use the Select button to find the framework under the current SDK folder.

Also, make sure the "Relative to current SDK" option is selected just below the path you see.

0


source


When you added the frameworks to your project, you checked the YES box when asked if you wanted to copy the framework to your project folder. If so, check the No box.

This also happens if you create a new project and try to run it without adding anything, because it is possible that you accidentally changed the compilation flags in that project.

0


source


This needs to be fixed by adding this to the compiler options:

-D__IPHONE_OS_VERSION_MIN_REQUIRED=30000

      

0


source


I ran into this issue when changing my project from sdk 3.2 to 4.1. It turns out the solution was changing the iOS Deployment Target in my project's build settings from 2.0 to 3.0 .

Right click your project in xcode (if you are using it), build, iOS Target -> 3.0.

0


source







All Articles