I am learning objective-c and XCode using Stephen Kochan's book. For one of the assignments, I needed to implement an AddressBook lookup feature from the command line. I used two classes from a previous project, added the files and did not make a copy. All builds fine in XCode, but when I issue the following command at the command line:
clang -fobjc-arc -framework Foundation main.m -o ch19
I get the error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_AddresBook", referenced from:
objc-class-ref in cc-bx2cgt.o
"_OBJC_CLASS_$_AddressCard", referenced from:
objc-class-ref in cc-bx2cgt.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
No typo in AddresBook, my class name has one "s". I tried removing the files (AddresBook.h and .m and AddressCard.h and .m) from my project, adding them with and without copying. Building and running the app in XCode works just fine.
How can I "clear" out the references and add them again so that I can compile it from the command line?
Thank you.
You need to add those other files object codes.
clang -fobjc-arc -framework Foundation main.m AddressBook.m -o ch19 or compile them to object files and then link them.
You should also be using xcodebuild for this, if you want to do it on the command line.
Related
I added some .m, .h files(include xxxController.m, xxxController.h) and libraries(include abc.a) to my xcode project same as the sample project which runs very well but this error occured:
duplicate symbol 'OBJC_IVAR$xxxController.xxx' in:
/Users/xxx/Library/Developer/Xcode/DerivedData/xxx/Build/Intermediates.noindex/xxx.build/Debug-iphoneos/xxx.build/Objects-normal/arm64/xxxController.o
../lib/xxx/lib/abc.a(xxx.o) ld: 15 duplicate symbols for architecture
arm64 clang: error: linker command failed with exit code 1 (use -v to
see invocation)
I changed enable testability option and no common blocks option to NO but still fail to build.
Also there are no duplicates in the compile source and removing derived data or cleaning build folder didn't work for me.
And when I remove '-Objc' in Other Linker Flags, it occurs 'Undefined symbol: OBJC_CLASS$_FIRInstallations' error. How can I fix it?
i get the following error when i run j2objcc -o blssmibi BLSSMIBI.o
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Curve", referenced from:
objc-class-ref in BLSSMIBI.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
what should i do to fix this?
There's no Curve class anywhere in j2objc's libraries, so my guess it's a dependency from the Java file that you used to generate BLSSMIBI (maybe that's the it looks like a package prefix was used). If you aren't sure what a class's dependencies are, try compiling with javac to a temporary directory and see what name.class files are created (ignore the ones with $ in their names, as they're inner classes). That list of class files is used to figure out all the classes that need transpiling, as well as all the .o files that the app requires.
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.
So I'm building an application with CorePlot, and when I tried to run it i got the following errors:
ld: warning: ignoring file /Users/tcbl/Library/Developer/Xcode/DerivedData/FaceTracker- chbhtqlxwipamtailjamrakmkpuy/Build/Products/Debug-iphoneos/libCorePlot-CocoaTouch.a,
file was built for archive which is not the architecture being linked (armv6)
ld: duplicate symbol _main in /Users/tcbl/Library/Developer/Xcode/DerivedData/FaceTracker-chbhtqlxwipamtailjamrakmkpuy/Build/Intermediates/FaceTracker.build/Debug-iphoneos/FaceTracker.build/Objects-normal/armv6/main-cocoatouch.o and /Users/tcbl/Library/Developer/Xcode/DerivedData/FaceTracker-chbhtqlxwipamtailjamrakmkpuy/Build/Intermediates/FaceTracker.build/Debug-iphoneos/FaceTracker.build/Objects-normal/armv6/main.o for architecture armv6
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I read somewhere that I need to add to other linker flags: -ObjC -all_load -lCorePlot But this doesn't seem to be anywhere in the project info or build settings, and I'm not sure if this even has anything to do with my error. Any help demystifying this would be much appreciated.
If you select your project and go to the Build Settings tab, you should find it listed under Linking. Make sure you have the advanced/complete view of the tab. The field you want to enter those under is "Other Linker Flags".
Hope that helps!
I am trying to Fetch Videos from YouTube Channel on Cocoa Application. For that First added GData Framework to my project, and import #import "GData/GData.h". Then their is no error . But if i am importing #import "GData/GDataServiceGoogleYouTube.h"
and write some code related to GDataServiceGoogleYouTube
GDataServiceGoogleYouTube *service=[[GDataServiceGoogleYouTube alloc]init];
getting Compiler eror:
Ld /Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth/Build/Products/Debug/YouTube.app/Contents/MacOS/YouTube normal x86_64
cd /Users/Rasheed/Desktop/MULTIPLESOCKET/YouTube
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/clang -arch x86_64 -isysroot
/Developer/SDKs/MacOSX10.6.sdk -L/Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth/Build/Products/Debug
-F/Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth/Build/Products/Debug -filelist
/Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth
/Build/Intermediates/YouTube.build/Debug/YouTube.build/Objects-normal/x86_64/YouTube.LinkFileList -mmacosx-version-min=10.6 -ObjC
-lxml2 -all_load -framework Cocoa -o /Users/Rasheed/Library/Developer/Xcode/DerivedData/YouTube-ddawzlgkbmkdqsalghaobsospjth/Build
/Products/Debug/YouTube.app/Contents/MacOS/YouTube
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GDataServiceGoogleYouTube", referenced from:
objc-class-ref in YouTubeAppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can i Fix This error?
If you built a GData static library, make sure the library is listed in the “Link Binary With Libraries” section under the “Build Phases” tab for your target.
If you dragged all of the GData source files into your project, make sure they are all listed in the “Compile Sources” section under the “Build Phases” tab for your target.
You might find this blog post helpful: http://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/