Build Error: ld: Duplicate Symbol _canVirate
Below is my build log. I've tried all the usual error-fixing solutions: Deleting build folder, cleaning, restarting Xcode, etc.
Ld build/Debug-iphonesimulator/SquirrelGame.app/SquirrelGame normal i386 cd /Users/Student/Desktop/SquirrelGame setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -L/Users/Student/Desktop/SquirrelGame/build/Debug-iphonesimulator -F/Users/Student/Desktop/SquirrelGame/build/Debug-iphonesimulator -F/Users/Student/Desktop/SquirrelGame -filelist /Users/Student/Desktop/SquirrelGame/build/SquirrelGame.build/Debug-iphonesimulator/SquirrelGame.build/Objects-normal/i386/SquirrelGame.LinkFileList -mmacosx-version-min=10.6 -all_load -ObjC -Xlinker -objc_abi_version -Xlinker 2 -weak_framework Foundation -weak_framework UIKit -framework CoreGraphics -framework AudioToolbox -framework CFNetwork -framework CoreLocation -weak_framework MapKit -framework QuartzCore -framework Security -framework S开发者_如何学PythonystemConfiguration -lsqlite3.0 -framework MediaPlayer -framework AVFoundation -framework MessageUI -framework MobileCoreServices -framework AddressBook -framework AddressBookUI -weak_framework GameKit -lz.1.2.3 -framework OpenFeint -o /Users/Student/Desktop/SquirrelGame/build/Debug-iphonesimulator/SquirrelGame.app/SquirrelGame
ld: duplicate symbol _canVirate in /Users/Student/Desktop/SquirrelGame/build/SquirrelGame.build/Debug-iphonesimulator/SquirrelGame.build/Objects-normal/i386/SquirrelGameViewController.o and /Users/Student/Desktop/SquirrelGame/build/SquirrelGame.build/Debug-iphonesimulator/SquirrelGame.build/Objects-normal/i386/SquirrelGameAppDelegate.o collect2: ld returned 1 exit status Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 failed with exit code 1
It is hard to say exactly without code, so please post canVirate definition. Usually that error means that canVirate is global variable defined in header file. Compiler creates the variable in every module that includes the header. You should declare canVirate in header, but define it in SomeModule.m file:
SomeModule.h:
extern int canVirate;
SomeModule.m:
int canVirate = 123;
精彩评论