I've been fighting this for a few hours now and I'm getting fed up. My project builds fine with a debug simulator build , release simulator build and a debug device build, but for some reason it won't build with a release device build. I have a static library containing my cocos2d code, and another static library containing a game engine I wrote.
Because the game engine contains categories, I had to use the all_load linker flag to get it to run. Without this flag, the code builds fine. However, I get an unrecognized selector sent to instance exception when I try to run the game.
Here's the first build error:
ld: duplicate symbol _OBJC_CLASS_$_FontLabel in /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libcocos2d.a(FontLabel.o) and /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libcocos2d.a(FontLabel.o)
Ld build/Shapeless.build/Release-iphoneos/Shapeless.build/Objects-normal/armv6/Shapeless normal armv6
cd /Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless
setenv IPHONEOS_DEPLOYMENT_TARGET 4.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk -L/Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless/build/Release-iphoneos -F/Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless/build/Release-iphoneos -filelist /Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless/build/Shapeless.build/Release-iphoneos/Shapeless.build/Objects-normal/armv6/Shapeless.LinkFileList -dead_strip -ObjC -all_load -miphoneos-version-min=4.0 /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libChipmunk.a /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libcocos2d.a /Users/helixed/Dropbox/Documents/Development/iPhone/BlackHawk/build/Release-iphoneos/libBlackHawk.a -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -framework OpenGLES -framework OpenAL -framework AVFoundation -framework AudioToolbox -lz -framework iAd -o /Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless/build/Shapeless.build/Release-iphoneos/Shapeless.build/Objects-normal/armv6/Shapeless
ld: duplicate symbol _OBJC_CLASS_$_FontLabel in /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libcocos2d.a(FontLabel.o) and /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libcocos2d.a(FontLabel.o)
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 failed with exit code 1
And here's the second:
Ld build/Shapeless.build/Release-iphoneos/Shapeless.build/Objects-normal/armv7/Shapeless normal armv7
cd /Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless
setenv IPHONEOS_DEPLOYMENT_TARGET 4.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk -L/Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless/build/Release-iphoneos -F/Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless/build/Release-iphoneos -filelist /Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless/build/Shapeless.build/Release-iphoneos/Shapeless.build/Objects-normal/armv7/Shapeless.LinkFileList -dead_strip -ObjC -all_load -miphoneos-version-min=4.0 /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libChipmunk.a /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libcocos2d.a /Users/helixed/Dropbox/Documents/Development/iPhone/BlackHawk/build/Release-iphoneos/libBlackHawk.a -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -framework OpenGLES -framework OpenAL -framework AVFoundation -framework AudioToolbox -lz -framework iAd -o /Users/helixed/Dropbox/Documents/Development/iPhone/Apps/Shapeless/build/Shapeless.build/Release-iphoneos/Shapeless.build/Objects-normal/armv7/Shapeless
ld: duplicate symbol _OBJC_CLASS_$_FontLabel in /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libcocos2d.a(FontLabel.o) and /Users/helixed/Dropbox/Documents/Development/iPhone/Cocos2d/build/Release-iphoneos/libcocos2d.a(FontLabel.o)
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 failed with exit code 1
This is the only think keeping me from releasing, so I really appreciate the help.
Thanks.
I faced a similar problem, I had accidentally included (#import) the implementation file instead of the header file
When the compiler throws an error that 2 object files contain a duplicate symbol, check for how you have included (#import) the that duplicate symbol's class in the 2 implementation files.
I had this problem with adding both Facebook sdk and Dropbox sdk. The problem was both of the SDks are using having JSON lib so I removed one of them ans it works now.
Do you have it twice in your project structure? Check the left side of XCode and look through all the folders and make sure you don't have it in there multiple times.
Do you have a different set of device architectures (armv6, armv7, etc.) in your Release build than in your Debug build settings (either project, or target which overrides project settings)?
I think the solution to your problem lies in the unrecognized selector issue that you tried to solve using the -all_load flag. I use cocos2d-iphone in a static library and didn't need that flag. If you read up what it does, it should tell you that it's unlikely to be related to your problem:
What does the -all_load linker flag do?
It fixes linking to static libraries containing ONLY categories and NO classes. That certainly isn't true for cocos2d-iphone.
I recommend to figure out why you get unrecognized selector warnings without this flag. If necessary ask another question here.
You should also turn on the "Unrecognized Selector" build warning in the project's Build Settings, so that you get this warning while compiling as opposed to when it crashes while running the game (then it's too late and you wasted a lot of time). It's one of the settings I always turn on in an Xcode project.
Related
I have this weird problem.
I'm trying to move to XCode 4.2, so I opened my project in XCode 4.2 and tried to build my project for iOS device. The build failed with no issues or any explanation. The weirdest thing is that the project is built with no problems for the Simulator and on XCode 3.2.6 (device and simulator).
This is the result I get when building:
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 failed with exit code 1
With no other issues.
I checked my Bundle Identifier and Product name and they do not contain illegal characters (only a-zA-Z).
I Also tried building with Apple's LLVM 3.0 which got the same result.
Provisioning profile was also double-checked.
Is there anything else that could cause that? What can I do?
edit:
Here are the details from the log:
Ld /Users/user/Library/Developer/Xcode/DerivedData/MyApp-dyvsuphvmlexzzghpgbnkfzmtqas/Build/Products/Debug-iphoneos/MyApp.app/MyApp normal armv7
cd /Users/user/Documents/Projects/MyApp
setenv IPHONEOS_DEPLOYMENT_TARGET 4.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Users/user/Library/Developer/Xcode/DerivedData/MyApp-dyvsuphvmlexzzghpgbnkfzmtqas/Build/Products/Debug-iphoneos -LRouteMe/MapView -LRouteMe/MapView/GTM -LRouteMe/MapView/Map -LRouteMe/MapView/UnitTesting -LRouteMe/MapView/Map/Cache.xcdatamodel -LRouteMe/MapView/Map/FMDB -LRouteMe/MapView/Map/Resources -F/Users/user/Library/Developer/Xcode/DerivedData/MyApp-dyvsuphvmlexzzghpgbnkfzmtqas/Build/Products/Debug-iphoneos -filelist /Users/user/Library/Developer/Xcode/DerivedData/MyApp-dyvsuphvmlexzzghpgbnkfzmtqas/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/MyApp.LinkFileList -dead_strip -ObjC -all_load -miphoneos-version-min=4.0 /Users/user/Library/Developer/Xcode/DerivedData/MyApp-dyvsuphvmlexzzghpgbnkfzmtqas/Build/Products/Debug-iphoneos/libMapView.a -framework AudioToolbox -framework AVFoundation -framework CoreGraphics -framework CoreLocation -framework Foundation -framework MapKit -framework MediaPlayer -framework OpenAL -framework QuartzCore -framework SystemConfiguration -framework UIKit -lsqlite3.0 -lstdc++.6 -framework CoreData -framework StoreKit -framework CoreMotion -o /Users/user/Library/Developer/Xcode/DerivedData/MyApp-dyvsuphvmlexzzghpgbnkfzmtqas/Build/Products/Debug-iphoneos/MyApp.app/MyApp
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 failed with exit code 1
I've finally found the solution! (thanks to Jesse Rusak's advice)
I used CloudMade's library for displaying a map. This library probably caused the problem.
I removed the library and removed all the library and header search paths to it.
After that I changed the base SDK of CloudMade's projects to "Latest iOS" and re-added the library to my project again. Re-added it to the library and header search path and thats it! it worked!
Thanks everyone!
d /Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Products/Debug-iphonesimulator/Goozzy.app/Goozzy normal i386
cd /Users/yariksmirnov/Desktop/Goozy/branches/new
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/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Products/Debug-iphonesimulator -F/Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Products/Debug-iphonesimulator -filelist /Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Intermediates/Goozzy.build/Debug-iphonesimulator/Goozzy.build/Objects-normal/i386/Goozzy.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40300 -framework CoreData -lz.1.2.3 -framework MobileCoreServices -framework SystemConfiguration -framework CFNetwork -framework QuartzCore -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Products/Debug-iphonesimulator/Goozzy.app/Goozzy
*ld: library not found for -lz.1.2.3*
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
How do I fix this error?
It's very strange -- I compile a build for iOS, but get a error about Mac OS deployment target.
You should link libz.dylib not any specific version. The correct version gets used automatically.
Update the libz dylib version in your project definition to whatever your XCode 4.2 is providing. If you are compiling the same code for different targets, check the library version on each of them.
Since SDK 3.2 all versions of libz are symbolic links to the last version (libz.1.2.3 in SDK 4.3), so regardless of what libz-version you choose, you get the last one. See /Developer/Platforms/iPhoneOS.platform/DeviceSupport/Latest/Symbols/usr/lib.
I don't know what Apple will do in the future. If you link to libz you are likely to keep linking to the latest version. A change in the major number of the library (libz-X) could break compatibility, so a safer choice is to keep linking the same version you have now. Your choice.
I am getting Apple Mach-O Linker Id error, while compiling the iphone app. And getting below error
Ld
"/Users/adminbluepal/Library/Developer/Xcode/DerivedData/Tiger-czyksblsmfqdqybamuutemvjbdek/Build/Products/Debug-iphonesimulator/Tiger
Dev.app/Tiger Dev" normal i386
cd /Users/adminbluepal/Desktop/Dir-Tiger_latest
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/gcc-4.2
-arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
-L/Users/adminbluepal/Library/Developer/Xcode/DerivedData/Tiger-czyksblsmfqdqybamuutemvjbdek/Build/Products/Debug-iphonesimulator
-F/Users/adminbluepal/Library/Developer/Xcode/DerivedData/Tiger-czyksblsmfqdqybamuutemvjbdek/Build/Products/Debug-iphonesimulator
-filelist "/Users/adminbluepal/Library/Developer/Xcode/DerivedData/Tiger-czyksblsmfqdqybamuutemvjbdek/Build/Intermediates/Tiger.build/Debug-iphonesimulator/Tiger.build/Objects-normal/i386/Tiger
Dev.LinkFileList" -Xlinker
--no-demangle -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -liLibs -framework AVFoundation -framework AudioToolbox -framework CoreMedia
-framework Foundation -framework GameKit -framework OpenGLES -framework
QuartzCore -framework Security
-framework SystemConfiguration -framework UIKit -lz -o "/Users/adminbluepal/Library/Developer/Xcode/DerivedData/Tiger-czyksblsmfqdqybamuutemvjbdek/Build/Products/Debug-iphonesimulator/Tiger
Dev.app/Tiger Dev"
ld: library not found for -liLibs
collect2: ld returned 1 exit status
Command
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
failed with exit code 1
Please help me out of this
Thank you,
Madan Mohan
Yesterday i had this problem.... cleared that error with the help of this answer. it may help you also...
You probably don't have the CoreGraphics.framework added to your frameworks list.
To make sure, click the "Frameworks" folder on Xcode. If the framework isn't listed on the table to the right, you'll need to add it by right-clicking the Frameworks folder, chooseing "Add Existing Framework..." and then choosing it from the list.
Source stack overflow previous question
Sounds like you're trying to use the iLibs library (Google says it's something for game development). XCode cannot properly link to it. Try adding their Framework to your project, or read the help docs of the library for help with its setup. Alternatively, see if you can remove the "-liLibs" linker flag in your build settings, if you aren't using the library.
Sorry I know this has been covered all over the place, only I can't fix this to save my life.
If someone could explain clearly what I might have done and what I might be able to do to fix this I would be forever grateful.
Here is my error:
Command /Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
ld: duplicate symbol _OBJC_IVAR_$_sunnyHillsTL._tileMap in /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos/libcocos2d libraries.a(sunnyHillsTL.o) and /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Intermediates/workingTitle.build/Debug-iphoneos/workingTitle.build/Objects-normal/armv7/sunnyHillsTL.o
Ld /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos/workingTitle.app/workingTitle normal armv7
cd "/Users/kahanejosh/Documents/iPhone:Mac Dev/Working Title/workingTitle"
setenv IPHONEOS_DEPLOYMENT_TARGET 3.0
setenv PATH "/Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin:/Xcode 4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
"/Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2" -arch armv7 -isysroot "/Xcode 4/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk" -L/Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos -F/Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos -filelist /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Intermediates/workingTitle.build/Debug-iphoneos/workingTitle.build/Objects-normal/armv7/workingTitle.LinkFileList -dead_strip -all_load -ObjC -miphoneos-version-min=3.0 -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit -framework AudioToolbox -framework OpenAL -lz -framework AVFoundation "-lcocos2d libraries" -o /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos/workingTitle.app/workingTitle
ld: duplicate symbol _OBJC_IVAR_$_sunnyHillsTL._tileMap in /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos/libcocos2d libraries.a(sunnyHillsTL.o) and /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Intermediates/workingTitle.build/Debug-iphoneos/workingTitle.build/Objects-normal/armv7/sunnyHillsTL.o
collect2: ld returned 1 exit status
Command /Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
It looks like you have two targets set up and your source is getting used in both. So, you create a static library with the sunnyHillsTL class that gets put into libcocoas2d libraries.a and then you are using the same object file as well. Either don't directly use the class in your target (don't add the class to the target) if you're using the library, or don't have this class be compiled as part of the static library.
Seems like you have two instance variables named «tileMap» in your «sunnyHillsTL» class...
install Command Line Tools from your Xcode.
in Xcode -> Preferences -> Downloads -> Components ->Command Line Tools
i downloaded a project and i want to try it, but when i'm trying to compile it i get always this error:
Build TuneIn Radio of project TuneInRadio with configuration Release
Ld "build/Release-iphonesimulator/TuneIn Radio.app/TuneIn Radio" normal i386
cd /Users/marco/Downloads/projects
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/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -L/Users/marco/Downloads/projects/build/Release-iphonesimulator -L/Users/marco/Downloads/projects -L/Users/marco/Downloads/projects/TuneInRadio-iphonesimulator -L/Users/marco/Downloads/projects/MMS/build/Release-iphonesimulator -L/Users/marco/Downloads/projects/ffmpeg/build/Release-iphonesimulator -F/Users/marco/Downloads/projects/build/Release-iphonesimulator -F/Users/marco/Downloads/projects -filelist "/Users/marco/Downloads/projects/build/TuneInRadio.build/Release-iphonesimulator/TuneIn Radio.build/Objects-normal/i386/TuneIn Radio.LinkFileList" -lTuneInRadio -llibmms -lffmpegLib -ObjC -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework CoreGraphics -framework QuartzCore -framework CoreFoundation -framework AudioToolbox -framework MediaPlayer -framework CoreLocation -framework UIKit -lz.1 -framework SystemConfiguration -framework MapKit -o "/Users/marco/Downloads/projects/build/Release-iphonesimulator/TuneIn Radio.app/TuneIn Radio"
ld: warning: directory '/Users/marco/Downloads/projects/TuneInRadio-iphonesimulator' following -L not found
ld: warning: directory '/Users/marco/Downloads/projects/MMS/build/Release-iphonesimulator' following -L not found
ld: library not found for -lTuneInRadio
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
Any advice on what kind of steps i can follow to reach the error ?
Thank's
The error indicates the problem:
ld: library not found for -lTuneInRadio
this means that your build/make is trying to find a library (called libTuneInRadio) to compile this program you're trying to build but it can't find it in the paths (the default ones + the ones described by the '-L' options on gcc call).
Not knowing any more about what you're compiling/building makes it impossible to say precisely what's happening other than you're missing this library.
Given the name of the library, it sounds like it should be part of the project you're trying to build (or maybe there is a related TuneInRadio-lib project), so I would suggest reading the README or BUILDING or similarly named file that might have come with the project to determine how to successfully compile this program.
I had the same problem compiling the project for iOS simulator, the problem is that the source code you downloaded does not contain the libTuneRadio.a library for TuneInRadio-iphonesimulator, so first create that folder and second move the libTuneRadio.a from TuneInRadio-iphoneos to the recently created folder. That should make it.
My application compiled successfully but it crashes as it cannot find any CasseteAudioPlayer class, so i guess there is still something wrong.