ld: library not found for -lz - objective-c

This is driving me crazy, when i try to compile on the simulator, everything is ok, but on the device i got this error:
ld: library not found for -lz
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1
Please help me understand the source of the problem:
Ld /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos/Fontenay-sous-Bois.app/Fontenay-sous-Bois normal armv7
cd /Users/ZConsulting/Desktop/Fontenay-sous-Bois
setenv IPHONEOS_DEPLOYMENT_TARGET 5.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/clang -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products
/Debug-iphoneos -F/Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
/iPhoneOS5.0.sdk/Developer/Library/Frameworks -filelist /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Intermediates/Fontenay-sous-Bois.build/Debug-iphoneos/Fontenay-sous-Bois.build/Objects-normal/armv7/Fontenay-sous-Bois.LinkFileList -dead_strip -fobjc-arc -miphoneos-version-min=5.0 -framework SenTestingKit -lz -lz.1.1.3 -framework MobileCoreServices
-framework SystemConfiguration -framework CFNetwork -framework CoreLocation -framework MapKit -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos/Fontenay-sous-Bois.app/Fontenay-sous-Bois
EDIT:
I did import the libz.1.1.3.dylib framework:
The only libz that i got in the Linked frameworks is the libz.1.1.3.dylib

You did specify the library libz.dylib in the Linked frameworks and Libraries item rather than the direct reference to libz.1.1.3 - in general you should use the most generic version of a library for compilation rather than a more specific one
Secondly, make sure that the libz.dylib is present under the iOS SDK - if it's missing, then it may be a mis-installed SDK (reinstall should fix that).
i.e.
find /Developer/Platforms -name libz.dylib
should result in a non-empty output for a libz.dylib under iPhoneOS5.0.sdk
Also see the answer to iPhone - Linker Error in Xcode 4.2 Preview, which is a similar issue to this.

i got the same error with a different library:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
to resolve this, under search paths -> user header search paths -> release i put:
"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include"
keep in mind that I get this bug only when I archive, and my archive is a based off my release scheme..
update:
I got the same problem (on a different occasion/project) for the lpods Library (ie cocoapods).. the way i figured out to solve this is by realizing that the build worked fine on my development scheme but not my debug scheme. basically the development scheme had no for build active architectures only whereas debug had yes. I simply changed debug to no in all the targets under cocoapods

Related

Error occur after add a UDP server and client

I am writing a program by using objective-c. Now I am going to add a UDP server and client into my project, before I add the file into xcode project, the project can be run successfully. But after I add another mainudp.m and upd.h and upd.m, the program cannot run and here is the error message, how to cope with this issue? Thanks
Ld /Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Products/Debug/dd.app/Contents/MacOS/dd normal x86_64
cd /Users/bacd/Desktop/de
export MACOSX_DEPLOYMENT_TARGET=10.7
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Products/Debug -F/Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Products/Debug -F/Users/bacd/Desktop/de/Bluewear\ OSX -filelist /Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Intermediates/dd.build/Debug/dd.build/Objects-normal/x86_64/dd.LinkFileList -mmacosx-version-min=10.7 -fobjc-arc -fobjc-link-runtime -framework AVFoundation -framework QuartzCore -framework CoreAudio -framework Carbon -framework IOBluetooth -framework Cocoa -framework CoreServices -Xlinker -dependency_info -Xlinker /Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Intermediates/dd.build/Debug/dd.build/Objects-normal/x86_64/dd_dependency_info.dat -o /Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Products/Debug/dd.app/Contents/MacOS/dd
duplicate symbol _main in:
/Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Intermediates/dd.build/Debug/dd.build/Objects-normal/x86_64/main.o
/Users/bacd/Library/Developer/Xcode/DerivedData/dd-hggkyympepqrutcpbxxlwmtzcjkb/Build/Intermediates/dd.build/Debug/dd.build/Objects-normal/x86_64/mainudp.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The new file (mainudp.m) must define a main() function, which is the entry-point into the program. You can only have one entry point and you already have one in your existing code.
You will either need to remove that new file or remove the main() function it contains and access any functionality it provides via your existing code.
Probably in your project you have dragged the whole 3rd party project, that's why there is two main() implementation one in your own project in main.m file and another in the third party project probably in mainudp.m file. That's why it is creating the issue. Try to drag drop only the useful classes not the whole project.

XCode/PhoneGap - Apple Mach-O Linker Error

I just finished programming my application. I tried to archive the App for submission, but it didn't work, the following error was displayed. This problem only happens when I want to archive the app, running on Test device or Simulator works perfect (no errors).
Ld /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp normal armv7
cd /Users/Admin/Desktop/MyApp3
setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos -L/Users/Admin/Desktop/MyApp3 -F/Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos -filelist /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/MyApp.LinkFileList -dead_strip -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak-lSystem -force_load /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/libCordova.a -ObjC -fobjc-link-runtime -miphoneos-version-min=6.1 -lxml2 -lxml2.2 -larchive.2 -framework CoreLocation -framework ImageIO -framework OpenAL -framework AssetsLibrary /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/libCordova.a -framework Foundation -weak_framework UIKit -framework CoreGraphics -framework AddressBook -framework AddressBookUI -framework AudioToolbox -weak_framework AVFoundation -framework CFNetwork -framework MediaPlayer -framework QuartzCore -framework SystemConfiguration -framework MobileCoreServices -weak_framework CoreMedia -framework CoreLocation -lCordova -o /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp
ld: file not found: /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/libCordova.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(null): File not found: /Users/Admin/Library/Developer/Xcode/DerivedData/Myapp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/Myapp/InstallationBuildProductsLocation/Applications/libCordova.a
(null): Linker command failed with exit code 1 (use -v to see invocation)
I already googled the ** out of this the past days. I tried everything I found. I set Build Active Architecture Only to "YES", deleted search paths (they were already empty), changed iOS Version, set Validate Build Product and other stuff.
I create my projects using terminal and ./create.
I even made a new clean project and posted my source code in there. The problem occures every time (even if I try to archive the new project without changing anything in source)
Using:
XCode 4.6.3
PhoneGap 2.9.0
I am desperate and hope for help. Thank you.
SOLUTION
I found a solution/work-around. (Couldn't post it because if 10Rep. limit, had to wait 8 hours)
In Target's Build Settings, find "Other Linker Flags"
Change $(TARGET_BUILD_DIR)/libCordova.a
To $(BUILT_PRODUCTS_DIR)/libCordova.a
Or just go to the Cordova site and download Cordova 3.0.0
(although the old known "splashscreen - white flash" is back)
With Cordova 3.0 this problem is fixed :)
Archiving works fine.
I am having the same issue... Works fine on simulator and test device, set Build Active Architecture to "YES" on both Cardova and MyApp projects, created using terminal ./create, rebuild the project from scratch.
Using: XCode 4.6.3 PhoneGap 2.9.0
Update:
Rebuilt my project with PhoneGap 3.0.0 and am now able to archive.
For me this was solved by setting "Build Active Architecture Only" to "Yes" for the "Release" setting in your Build Settings in xcode.
The fix described by FlyingLemon had already been done as I have the latest version of PhoneGap.
Phonegap version 3.4.0-0.19.13
Xcode version 5.1

Renaming Quicklook-template GeneratePreviewForURL.m causes linker error

I'm using a slightly outdated version of Xcode (4.2.1, with Apple clang version 3.0), which might be a problem, but.. this should work regardless:
I create a new Quicklook plugin project ("File > New > New Project", then "System Plugin > Quick Look Plug-in")
Then I rename GeneratePreviewForURL.c to GeneratePreviewForURL.m (as mentioned in the Apple docs)
If I try and use any Objective-C code in the file, I get errors. For example if I add the following to the GeneratePreviewForURL method:
#include <Foundation/Foundation.h> // at start of file
NSMutableDictionary *blah;
[blah setValue:#"valuething" forKey:#"keything"];
I get the following linker error:
Undefined symbols for architecture x86_64:
"_objc_msgSend", referenced from:
_GeneratePreviewForURL in GeneratePreviewForURL.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The slightly trimmed/reformmated linker command causing the problem is:
cd ~/QuicklookExample
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/clang
-arch x86_64 -bundle
-isysroot /Developer/SDKs/MacOSX10.7.sdk
-L/snip -F/snip -filelist /snip/QuicklookExample.LinkFileList
-mmacosx-version-min=10.7
-framework QuickLook
-framework ApplicationServices
-framework CoreServices
-framework CoreFoundation
-o /snip/QuicklookExample
You have to add at least Foundation framework to the linked libraries.
Note that what's missing here is libobjc which should be linked directly by the fact clang should understand your code is actually Objective-C.

Error linking Facebook library with MGTwitterEngine

I am trying to integrate Facebook into my app and have already implemented MGTwitterEngine with no issues. I keep getting an error now that I have tried to implement both Facebook sdk and MGTwitterEngine. I have read that there is a duplicate library between both SDK's and the individual said it had to do with the JSON Libraries. I deleted it from the Facebook sdk but I am still getting the error. Does anyone know what the issue may be?
So I understand it is referring to my armv6 in the error but there is no error at all until I try running Facebook sdk
Thanks
Ld "/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/grocery.build/Objects-normal/armv6/grocery" normal armv6
cd /Users/Alex/Documents/Dictator/Lotto
setenv IPHONEOS_DEPLOYMENT_TARGET 3.1
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -L/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Products/Release-iphoneos "-L/Users/Alex/Documents/Dictator/Lotto/Classes/Twitter+OAuth 2/SAOAuthTwitterEngine" -F/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Products/Release-iphoneos -filelist "/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/grocery.build/Objects-normal/armv6/grocery.LinkFileList" -dead_strip -miphoneos-version-min=3.1 -framework Security -lxml2 -framework MessageUI -framework Foundation -framework UIKit -framework CoreGraphics -framework CoreData -framework MapKit -framework SystemConfiguration -lOAuth -o "/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/Lotto Fetcher.build/Objects-normal/armv6/grocery"
ld: duplicate symbol _main in /Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/Lotto Fetcher.build/Objects-normal/armv6/main-280587BD193E8878.o and /Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/Lotto Fetcher.build/Objects-normal/armv6/main-B9843B6026D6EFA4.o for architecture armv6
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Duplicate symbol
Search your project for two copies of main.m file. :-)

Apple mach-o linker flag error

I am trying to add TapJoy in my app, after adding the TapJoy class I got this error:
Ld /Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Intermediates/Tapjoy.build/Debug-iphoneos/Tapjoy.build/Objects-normal/armv6/Tapjoy normal armv6
cd /Tamanna/Tapjoy
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 armv6 -isysroot "/Xcode 4/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk" -L/Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Products/Debug-iphoneos -F/Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Products/Debug-iphoneos -filelist /Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Intermediates/Tapjoy.build/Debug-iphoneos/Tapjoy.build/Objects-normal/armv6/Tapjoy.LinkFileList -dead_strip libxml2 -miphoneos-version-min=3.0 -framework CoreTelephony -framework QuartzCore -framework OpenGLES -framework OpenAL -framework AudioToolbox -framework AVFoundation -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Intermediates/Tapjoy.build/Debug-iphoneos/Tapjoy.build/Objects-normal/armv6/Tapjoy
arm-apple-darwin10-llvm-gcc-4.2: libxml2: No such file or directory
Command /Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
Can anyone help ?
The relevant part of that log is:
libxml2: No such file or directory
You will want to add the libxml2 library to your project's "Link Binary with Libraries" Build Phase. I believe it's named libxml2.dylib, there may be multiple versions differing in version number.
If the library is already added, remove it and re-add it. It may be linked to the wrong Xcode installation, or the particular version may have been removed or renamed in the latest Xcode.