How to solve "Undefined symbols for architecture x86_64:"? - objective-c

I've done hours and hours of searching and still no luck (read a lot of stackoverflow as well).
I am trying to implement FDTake via Cocoapods. When I try and run it I get the following:
undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FDTakeController", referenced from:
objc-class-ref in VendeViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I know there is many similar questions around SO but all their solutions don't seem to work for me.

From the logs I can assume that you would be using a static library which is not build for simulator(architecture x86_64).
The library is only compiled for device and it needs to be complied and build for simulator also. Then the two static files (one abc.a for device and one abc.a for simulator) needs to be fat file i.e these files should be merged together using lipo command on terminal to create a fat file. Now when you use this fat file it will work both for simulator as well as device.
But the important thing is that you should have the source to compile and build the static libraries for simulator and device. After which you merge these to create a fat file which will work on all the defined architectures.
In case you are using third party static library (SDK) then you need to contact the respected party.

Related

iOS manually exporting library causes issues

I made a library and I want to test it in a dummy project I made. Both projects are made in Objective-C. When I build my library I get a Successful Build message and three files under the Product directory:
FooIOS.bundle
libFooIOS.a
include
I place these three files at the root level of my dummy project and when I open my myDummyProject.xcworkspace file I see them in my project hierarchy. However, when I build my project I get the following error:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_FooSelectedPageViewController", referenced from:
objc-class-ref in libFooIOS.a(FooViewController.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I did away with some of the obvious checks:
Made sure to reference my external library
I also made sure that both my library and project architectures are set as armv7 arm64
I don't know what else to do. I may be missing another configuration step or it may even be the way I declared something in my library that doesn't conform with my dummy project. Or a discrepancy between projects, perhaps? Any hints or leads would be a great help. Thanks.

ffmpeg 64bit Xcode

I'm trying to use the ffmpeg libraries in Xcode on Mac. I want to address to 64bit-systems like Lion and Mountain Lion. I tried to compile with
./configure --enable-static --enable-nonfree --enable-version3 --enable-gpl --disable-doc --disable-programs --arch=x86_64 --cc=cc --disable-yasm --host-cflags="-arch x86_64" --host-ldflags="-arch x86_64" --prefix=ffmpeg
Then I copied the ffmpeg-directory (with lib and include folders) into my project folder. I added the .a-files to my project and added the .a files to "Link binaries with Libraries"). Also I adjusted the header and library folder in the project settings. So far so good.
I'm a beginner with those libraries, so I started with opening a video. Works fine.
Now I'm trying to decode a given input file. Therefore I looked at this example file: http://ffmpeg.org/doxygen/1.0/decoding__encoding_8c-source.html
I copied the video_decode_example function. But at compiling I'm getting the following error:
Undefined symbols for architecture x86_64:
"_decode_write_frame", referenced from:
_video_decode_example in cutClass.o
ld: symbol(s) not found for architecture x86_64
What did I wrong at compiling ffmpeg?
decode_write_frame() is not part of ffmpeg — it's part of the sample code you were referring to. Read the sample code more closely and implement your own equivalent. (The implementation in the decoding_encoding.c sample is almost certainly not something you'd want in production code -- it just writes every frame to disk as a PGM image file.)

Issues including C++ files with Objective C on iOS

I'm trying to include several different items from AudioCore, in particular, AQRecorder. This does, however, have dependencies on c++ code. Normally this is not an issue as I just rename my view controller to have the extension .mm and everything is great. But in this case, my dependency on AQRecorder.h indirectly goes to my main.m which is causing me great pain.
I've tried several different things including the following:
1) Changing all .m and .cpp files -> .mm files
Everything compiles perfectly, however, it can't deploy to my iOS device or simulator as I get this error when deploying to the device:
"Choose a destination with a supported architecture in order to run on
this device."
I'm using XCode 4.6 and my valid architectures are armv7 & armv7s (I've played with these but with no luck).
2) Tried using opaque pointers such as that in this guide:
http://philjordan.eu/article/mixing-objective-c-c++-and-objective-c++
I still run into the same issue where it won't compile.
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_AQWrappedRecorder", referenced from:
objc-class-ref in RTPPacketSender.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My dependencies are as follows:
AQRecorder.h -> RTPPacketSender.h -> ActiveConversationViewController.h -> ConversationViewController.h -> AppDelegate.h -> main.m
Can anybody else recommend anything to try. I've quite literally spent all day debugging this issue with no luck.
Vince

TouchJSON Fails on Compile (link error)

Undefined symbols for architecture x86_64:
"_objc_unretainedPointer", referenced from:
-[CJSONScanner scanJSONStringConstant:error:] in CJSONScanner.o
-[CJSONSerializer serializeNumber:error:] in CJSONSerializer.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Hey all. Trying to use TouchJSON to do some JSON-y stuff. I followed the read me for the library to the meter I think, but every time I try to compile I get this error. I don't know much about Xcode (I've only been learning Obj-C recently) so I'm clueless about this. Any ideas?
Try to remove "Experimental" folder (and files inside, of course).
README
Be aware that the code in the Experimental subdirectory of Source is
just that and may not have been extensively tested and/or have extra
dependencies
So it could be a problem about extra dependencies (but always make sure if your project already have linked all dependency libraries/framework)

Conditionally linking for #autoreleasepool

When I try to run my application in the iOS 4.3 simulator (Xcode 4.2), I crash when I hit #autoreleasepool{}, with:
dyld: lazy symbol binding failed: Symbol not found: _objc_autoreleasePoolPush
I looked around, and I see the workaround is to add libarclite_iphoneos.a. There's a version of this for the simulator, too, as libarclite_iphonesimulator.a.
I need to add both libraries to my project to make it run on both the simulator and hardware. But whichever I build, it complains that the other library is for an unsupported architecture.
For example, building for simulator:
ld: warning: ignoring file /Developer-4.2/Platforms/iPhoneOS.platform/
Developer/usr/lib/arc/libarclite_iphoneos.a, missing required architecture
i386 in file
How do I fix both of these simultaneously? Or should I just stick with the old NSAutoreleasePool syntax for now?
After a trials like clean, clean folder, resetting iPhone Simulator and even a restart, I changed the IPHONE_DEPLYMENT_TARGET on the target build setting down from iOS 5.0 to iOS 4.2.
Worked.
You can use the Other Linker Flags build setting to link in the library, and specialize the value based on whether it's "Any iOS" or "Any iOS Simulator".
You can also merge the two static libraries to one universal library. Go to the Terminal and say
lipo -create -output /where/you/want/it/libarclite_universal.a /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/arc/libarclite_iphoneos.a /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/arc/libarclite_iphonesimulator.a
You can verify the resulting file by saying (in Terminal)
file /where/you/put/it/libarclite_universal.a
It should output:
libarclite_universal.a: Mach-O universal binary with 3 architectures
libarclite_universal.a (for architecture i386):current ar archive random library
libarclite_universal.a (for architecture armv6):current ar archive random library
libarclite_universal.a (for architecture armv7):current ar archive random library
Since this lib is linked statically, your final app wont grow because of the included sim library since only whatever is needed by your app will get linked into your final app.