【问题标题】:Problem compiling a simple test project for the iPhone为 iPhone 编译一个简单的测试项目时出现问题
【发布时间】:2009-09-24 18:47:55
【问题描述】:

我是 iphone 开发新手。我在 delegate.h 部分中有这段代码:

#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

当我编译我得到这个错误:

ld:在 /Users/ianbennett/Desktop/iphone development/Learning1/build/Learning1.build/Debug-iphonesimulator/Learning1.build/Objects-normal/i386/Learning1AppDelegate.o 和 /Users/ianbennett/ 中重复符号 _main桌面/iphone开发/Learning1/build/Learning1.build/Debug-iphonesimulator/Learning1.build/Objects-normal/i386/main.o

command/Developer/platforms/iphoneSimulator.platform/Developer/usr/bin/gcc-4.2 失败,退出代码为 1

我看到其他人也有类似的错误,这可能与我的库有关,但我不确定如何修复它。

【问题讨论】:

  • 这是错误中的最后一行,所有错误都会给出这个。第一行是有用的
  • 我已经添加了其余部分。谢谢

标签: objective-c iphone-sdk-3.0


【解决方案1】:

您已经定义了两次 main() 函数(看起来它是在 Learning1AppDelegate.mma​​in.m

中定义的

【讨论】:

    【解决方案2】:

    感谢您的错误信息

    你在 2 个地方定义了相同的 main 函数

    文件是

    主要 Learning1AppDelegate

    你只能在一个地方定义一个函数——所以你必须选择

    【讨论】:

      猜你喜欢
      • 2018-05-18
      • 2011-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-17
      • 2011-04-27
      • 1970-01-01
      相关资源
      最近更新 更多