views:

104

answers:

2

I am new to iphone development. I have this code in the delegate.h section:

#import <UIKit/UIKit.h>
#import <objc/Object.h>

@class Learning1ViewController;

@interface  Greeter: NSObject<UIApplicationDelegate>
{
}
-(void)greet;

@end

#include <stdio.h>

@implementation Greeter
-(void) greet
{
    printf ("Hello, World!\n");
}

#include <stdlib.h>

int main(void)
{
    id myGreeter;
    myGreeter=[Greeter new];
    [myGreeter greet];
    [myGreeter free];
    return EXIT_SUCCESS;
}
@end

@interface Learning1AppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    Learning1ViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet Learning1ViewController *viewController;

@end

When i compile i get this error:

ld: duplicate symbol _main in /Users/ianbennett/Desktop/iphone development/Learning1/build/Learning1.build/Debug-iphonesimulator/Learning1.build/Objects-normal/i386/Learning1AppDelegate.o and /Users/ianbennett/Desktop/iphone development/Learning1/build/Learning1.build/Debug-iphonesimulator/Learning1.build/Objects-normal/i386/main.o

command/Developer/platforms/iphoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

I have seen that other people have had similar errors and that it might be to do with my library but im not really sure how to fix it.

+1  A: 

You have defined the main() function twice (looks like it's defined in Learning1AppDelegate.m and main.m

Philippe Leybaert
A: 

Thanks for the error message

You have defined the same function main in 2 places

The files are

main Learning1AppDelegate

You can only define a function in one place - so you have to choose

Mark