collect2: ld returned 1 exit status error in Xcode
- by user573949
Hello,
Im getting the error
Command /Developer/usr/bin/gcc-4.2 failed with exit code 1
and when the full log is opened, the error is more accurately listed as:
collect2: ld returned 1 exit status
from this simple Cocoa script:
#import "Controller.h"
@implementation Controller
int skillcheck (int level, int modifer, int difficulty)
{
if (level + modifer >= difficulty)
{
return 1;
}
if (level + modifer <= difficulty)
{
return 0;
}
}
int main ()
{
skillcheck(10, 2, 10);
}
@end
the .h file is this:
//
// Controller.h
//
// Created by Duo Oratar on 15/01/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface Controller : NSObject
{
int skillcheck;
int contestcheck;
}
@end
and no line was specified that the error came from, does anyone know what the source of this error is, and more importantly, how to fix it?
EDIT:
I removed the class so now I have this:
//
// Controller.m
//
// Created by Duo Oratar on 15/01/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "Controller.h"
int skillcheck (int level, int modifer, int difficulty)
{
if (level + modifer >= difficulty)
{
return 1;
}
if (level + modifer <= difficulty)
{
return 0;
}
}
int main ()
{
skillcheck(10, 2, 10);
}
and for the .h file:
//
// Controller.h
//
// Created by Duo Oratar on 15/01/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
and the log says: (thanks to the guy who said how to open it)
Ld build/Debug/Calculator.app/Contents/MacOS/Calculator normal x86_64
cd /Users/kids/Desktop/Calculator
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/gcc-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -L/Users/kids/Desktop/Calculator/build/Debug -F/Users/kids/Desktop/Calculator/build/Debug -filelist /Users/kids/Desktop/Calculator/build/Calculator.build/Debug/Calculator.build/Objects-normal/x86_64/Calculator.LinkFileList -mmacosx-version-min=10.6 -framework Cocoa -o /Users/kids/Desktop/Calculator/build/Debug/Calculator.app/Contents/MacOS/Calculator
ld: duplicate symbol _main in /Users/kids/Desktop/Calculator/build/Calculator.build/Debug/Calculator.build/Objects-normal/x86_64/Controller.o and /Users/kids/Desktop/Calculator/build/Calculator.build/Debug/Calculator.build/Objects-normal/x86_64/main.o
collect2: ld returned 1 exit status
Command /Developer/usr/bin/gcc-4.2 failed with exit code 1
ld: duplicate symbol _main in /Users/kids/Desktop/Calculator/build/Calculator.build/Debug/Calculator.build/Objects-normal/x86_64/Controller.o and /Users/kids/Desktop/Calculator/build/Calculator.build/Debug/Calculator.build/Objects-normal/x86_64/main.o
Command /Developer/usr/bin/gcc-4.2 failed with exit code 1