In my project I have several linking errors, each of them points to libz missing. Here is the example:
Undefined symbols for architecture arm64:
"_inflateReset2", referenced from:
_png_inflate_claim in libcocos2d iOS.a(pngrutil.o)
"_inflateEnd", referenced from:
cocos2d::unzCloseCurrentFile(void*) in libcocos2d iOS.a(unzip.o)
cocos2d::ZipUtils::inflateMemoryWithHint(unsigned char*, long, unsigned char**, long*, long) in libcocos2d iOS.a(ZipUtils.o)
_png_destroy_read_struct in libcocos2d iOS.a(pngread.o)
+[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
_FT_Stream_OpenGzip in libcocos2d iOS.a(ftgzip.o)
_ft_gzip_stream_close in libcocos2d iOS.a(ftgzip.o)
_FT_Gzip_Uncompress in libcocos2d iOS.a(ftgzip.o)
...
"_deflate", referenced from:
+[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_deflateInit2_", referenced from:
+[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
"_inflateReset", referenced from:
_png_decompress_chunk in libcocos2d iOS.a(pngrutil.o)
_FT_Stream_OpenGzip in libcocos2d iOS.a(ftgzip.o)
_ft_gzip_file_io in libcocos2d iOS.a(ftgzip.o)
So looks like external libs (cocos2d & GA) can't find this lib. I have it in Link binary with libraries for my target, also have -lz flag in Other Linger flags. Removing any of those keep this errors.
What can cause this problem? How this might be resolved?
(I've already tried things like restarting XCode, cleaning derived data, etc)
There's something wonky with the current version of XCode. You need to purge all zlib / libz references from your previous attempts in your project, then open up /usr/lib in Finder and manually drag libz.dylib into your project alongside your source files. That's what just worked for me five minutes ago.
I don't know what's up. I have a prototype project using zlib which compiles properly, yet when I copied & pasted the zip code & copied the support files over to my real project, I was unable to compile, with the same zlib-missing errors. The prototype project keep compiling. No difference in setup between the projects! On my real project, I tried adding libz.dylib and it's non-linked version (libz.1.dylib), I tried manually adding the -lz to the linker build options, both to no avail. Yay Finder! I hope this works for you, too.
Related
The app I've been working on uses an external library, pdlib, which has it's own externals (.c files) which I've been importing via the bridging header #import "Uzi.c" and calling in my main Swift file via Uzi.c's setup function Uzi_setup() in my ViewController class. I've had no problem with this until after updating to new public Xcode 8 a few days ago (I had no problem with Xcode 8 Beta 1 over the Summer).
Here are the 7 errors I get, listed under a single "Mach-O Linker Error" umbrella:
Undefined symbols for architecture x86_64:
"_Uzi_bang", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_class", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_float", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_new", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_pause", referenced from:
_Uzi_setup in ViewController.o
"_Uzi_resume", referenced from:
_Uzi_setup in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Those undefined symbols are 6 functions and a class declare from Uzi.c. Here's a link to the whole c file: https://github.com/electrickery/pd-miXedSon/blob/master/hammer/Uzi.c
I've tried every solution I've found online for dealing with similar problems, with no solution yet... I tried changing the "Architecture" and "Valid Architecture" settings to only armv7 and armv7s (no arm64) and changed "Build Active Architecture Only" to "No". These step seem to help others in similar situations, but they didn't work for me (and taking away arm64 causes additional errors to appear).
XCode 8 is pretty recent (the public version was released Sept. 13), so there are virtually no other questions about this upgrade causing a similar problem.
Any help would be greatly appreciated!
Solved by #danomatika on GitHub: https://github.com/libpd/libpd/issues/149
"You generally shouldn't include/import an implementation file aka .c, .cpp, .m, etc. This is what is causing the duplicate symbol issue.
This is what the "forward function declaration" in the header file is for: to tell the compiler that a function exists and what data it takes/returns. The compiler then assumes the actual implementation of the function exists in an implementation file. If it can't be found, then you get an "undefined symbol error." If you somehow end up declaring the function twice, aka include both a header with the forward declaration and the implemetaton of the function itself in the .c file, then you get a "duplicate symbol error."
This is all lower-level stuff that is only really an issue since Pd externals are designed around being dynamic libraries, so are not built or provided with headers which include the function declarations. This is why you have to do a little extra work and do it yourself.
Their are two easy fixes for this, both of which involve declaring the required function you want to call from the .c file in a header file.
Simply declare the function in the bridging header:
void uzi_setup();
Create a header, say Externals.h, and declare all of the externals stuff there:
// forward declare setup functions only found in .c implementations
void uzi_setup();
// convenience wrapper function
void externals_setup() {
uzi_setup();
}
Then import the file in your bridging header:
#import "Externals.h"
And in swift, you can now do:
externals_setup()
I am getting this error which I try to add my OpenCV based library to a MonoTouch project:
Undefined symbols for architecture i386:
"cv::isContourConvex(cv::_InputArray const&)", referenced from:
aruco::MarkerDetector::detectRectangles(cv::Mat const&, std::vector<aruco::MarkerDetector::MarkerCandidate, std::allocator<aruco::MarkerDetector::MarkerCandidate> >&)in libAruco.a(markerdetector.o)
"cv::warpPerspective(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Size_<int>, int, int, cv::Scalar_<double> const&)", referenced from:
aruco::MarkerDetector::warp_cylinder(cv::Mat&, cv::Mat&, cv::Size_<int>, aruco::MarkerDetector::MarkerCandidate&)in libAruco.a(markerdetector.o)
aruco::MarkerDetector::warp(cv::Mat&, cv::Mat&, cv::Size_<int>, std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >)in libAruco.a(markerdetector.o)
"cv::FileNodeIterator::readRaw(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*, unsigned long)", referenced from:
cv::VecReaderProxy<float, 1>::operator()(std::vector<float, std::allocator<float> >&, unsigned long) constin libAruco.a(board.o)
"cv::FileNodeIterator::FileNodeIterator(CvFileStorage const*, CvFileNode const*, unsigned long)", referenced from:
cv::FileNode::begin() constin libAruco.a(board.o)
cv::FileNode::end() constin libAruco.a(board.o)
This is only a sample of the full list of opencv methods which are having this problem, as it is easily over 100.
I'm attempting to run this in the simulator (I only have the trial edition of monotouch). I'm compiling for the ipad simulator in xcode and have followed the Opencv tutorial as far as setting up my project with the pre-built framework from their website. I was maybe wondering if there is some linker flag I need to enter as my static library is not as large as I would expect it to be given the fact it needs to link with several of the opencv modules (that's just a gut feeling and not necessarily indicative of anything).
I suppose its also important to mention that I have very little experience with iOS and MonoTouch development, so I could have missed something really simple.
Your static library might not be a FAT (multiple architectures) library or may not include i386 code.
The easy way to find out is to try, from a terminal window:
lipo -info libAruco.a
That should return something like:
Architectures in the fat file: libAruco.a are: i386 ...
where ... is likely armv7 (or more) to support the iOS devices.
OTOH if i386 is missing then it means your library is not compiled to work on the simulator. In such case you'll need to return to Xcode to build this architecture and use lipo to create a FAT library (that includes both the arm and i386 architectures).
Need to generate QR code from iOS for different strings. Tried out the following library:
**jverkoey-ObjQREncoder-e1841fe**
being able to generate QR Code .. but this code cannot be read by any readers.
**iOS-QR-Code-Generator**
Following the documentation provided But facing linking problem when i am trying to add the 'kuapay-iOS-QR-Code-Generator' to generate QRCode. I followed the way that is written in the github project
"To build your own project from this template you must attace the libz.dylib library to your target in Xcode. You must also drag the QRDraw and libpng folder files into your project. Update the Header Search path to look in the libpng folder in your target build settings menu."
But it give me 6 error message. These are -
Undefined symbols for architecture i386:
"CQR_Encode::EncodeData(int, int, bool, int, char*, int)", referenced from:
-[RootViewController LoadQRImage] in RootViewController.o
"CQR_Encode::~CQR_Encode()", referenced from:
-[RootViewController LoadQRImage] in RootViewController.o
"_OBJC_CLASS_$_FileManager", referenced from:
objc-class-ref in RootViewController.o
"QRDrawPNG::draw(char*, int, int, unsigned char (*) [177], void*)", referenced from:
-[RootViewController LoadQRImage] in RootViewController.o
"CQR_Encode::CQR_Encode()", referenced from:
-[RootViewController LoadQRImage] in RootViewController.o
"vtable for QRDrawPNG", referenced from:
QRDrawPNG::QRDrawPNG() in RootViewController.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can anyone help me with this? OR suggest a better QRcode generator for iOS device?
Thanks a lot!
This issue is caused because you are using c++ code silently in your app , use .mm instead of .m in your RootViewController .
Check you have the file Barcode.mm, qr_draw_png.mm, QR_Encode.mm linked to your project target. Also you may be add "-fno-objc-arc" flag.
I am trying to include the World Magnetic Model code, written in C, into an iOS app. It includes a 8.5M header file that defines a float array with lots of elements. If I include it as is, I get linker errors about duplicate objects, probably because the header is included more than once by different compilation units and the float array is defined in the header file. This is somewhat expected.
I've tried splitting that up into a h file and a c file and declaring the float array as extern, but that didn't work.
Any ideas on how to solve this with as few modifications to the WMM code as possible?
Thanks
EDIT: This is how I tried to split the files up:
// EGM9615.h file
extern float GeoidHeightBuffer[];
// EGM9615.c file
#include "EGM9615.h"
float GeoidHeightBuffer[] =
{1.2, 1.2, // lots more
};
It results in linker errors still:
Undefined symbols for architecture armv7:
"__Z29WMM_TimelyModifyMagneticModel12WMMtype_DateP21WMMtype_MagneticModelS1_",
referenced from:
-[Waypoint magneticVariation] in Waypoint.o "__Z23WMM_GeodeticToSpherical17WMMtype_Ellipsoid21WMMtype_CoordGeodeticP22WMMtype_CoordSpherical",
referenced from:
-[Waypoint magneticVariation] in Waypoint.o "__Z26WMM_CalculateGridVariation21WMMtype_CoordGeodeticP27WMMtype_GeoMagneticElements",
referenced from:
-[Waypoint magneticVariation] in Waypoint.o "__Z10WMM_Geomag17WMMtype_Ellipsoid22WMMtype_CoordSpherical21WMMtype_CoordGeodeticP21WMMtype_MagneticModelP27WMMtype_GeoMagneticElements", referenced from:
-[Waypoint magneticVariation] in Waypoint.o "__Z23WMM_AllocateModelMemoryi", referenced from:
-[Waypoint magneticVariation] in Waypoint.o "__Z22WMM_GeomagIntroductionP21WMMtype_MagneticModelPc", referenced
from:
-[Waypoint magneticVariation] in Waypoint.o "__Z23WMM_robustReadMagModelsPcPP21WMMtype_MagneticModeli", referenced
from:
-[Waypoint magneticVariation] in Waypoint.o "__Z9WMM_Errori", referenced from:
-[Waypoint magneticVariation] in Waypoint.o "__Z15WMM_SetDefaultsP17WMMtype_EllipsoidP21WMMtype_MagneticModelP13WMMtype_Geoid",
referenced from:
-[Waypoint magneticVariation] in Waypoint.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with
exit code 1 (use -v to see invocation)
I've tried splitting that up into a h file and a c file and declaring the float array as extern, but that didn't work.
Then you did this incorrectly. This is the correct way to solve your problem. Take another look at what errors you saw when you split it up this way.
I am assuming here that when you say "duplicate objects" you mean duplicate identifiers at link time, not "objects."
EDIT: Your failed symbols have nothing to do with GeoidHeightBuffer. It looks like you're not linking whatever code provides WMM_TimelyModifyMagneticModel() and its friends. These appear to be C++ name-mangled. Are you compiling C code with a C++ compiler without using extern "C" {}?
I cannot compile my project for the device or simulator anymore. I get 13 Apple Mach-O-Linker errors. It all started after I failed attempt to use sharekit. Here is the log from the error:
ld: warning: directory not found for option '-F/Users/bbrandy95/Documents/Broken Brandsonic Web Projects/Brandsonic Web mobile/../../Downloads/0.2.1gm1/iphoneos4.0/System/Library/Frameworks'
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_NSURLRequest", referenced from:
objc-class-ref in Brandsonic_Web_mobileAppDelegate.o
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
objc-class-ref in main.o
"_objc_msgSendSuper2", referenced from:
-[Brandsonic_Web_mobileAppDelegate dealloc] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileViewController didReceiveMemoryWarning] in Brandsonic_Web_mobileViewController.o
-[Brandsonic_Web_mobileViewController dealloc] in Brandsonic_Web_mobileViewController.o
"_objc_setProperty", referenced from:
-[Brandsonic_Web_mobileAppDelegate setWindow:] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate setViewController:] in Brandsonic_Web_mobileAppDelegate.o
"__objc_empty_vtable", referenced from:
_OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_CLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_SecondView in SecondView.o
_OBJC_CLASS_$_SecondView in SecondView.o
"_objc_msgSend", referenced from:
_main in main.o
-[Brandsonic_Web_mobileAppDelegate application:didFinishLaunchingWithOptions:] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate dealloc] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate GOOGLE] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate YOUTUBE] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate WIKI] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileViewController webView:shouldStartLoadWithRequest:navigationType:] in Brandsonic_Web_mobileViewController.o
...
"__objc_empty_cache", referenced from:
_OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_CLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_SecondView in SecondView.o
_OBJC_CLASS_$_SecondView in SecondView.o
"_OBJC_CLASS_$_NSObject", referenced from:
_OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
"___CFConstantStringClassReference", referenced from:
CFString in Brandsonic_Web_mobileAppDelegate.o
CFString in Brandsonic_Web_mobileAppDelegate.o
CFString in Brandsonic_Web_mobileAppDelegate.o
CFString in Brandsonic_Web_mobileViewController.o
CFString in Brandsonic_Web_mobileViewController.o
CFString in Brandsonic_Web_mobileViewController.o
CFString in Brandsonic_Web_mobileViewController.o
...
"_OBJC_CLASS_$_NSKeyedUnarchiver", referenced from:
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_CLASS_$_NSUserDefaults", referenced from:
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_CLASS_$_NSURL", referenced from:
objc-class-ref in Brandsonic_Web_mobileAppDelegate.o
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_METACLASS_$_NSObject", referenced from:
_OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_SecondView in SecondView.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
'
How do I fix this? Please help.
For every one with an similar error.
If that happens you normally can remove the "Path" under Point
target->Build Settings->Library Search Paths
This error can occur when a framework is added to a project more than once.
You can fix this by removing the duplicate. To find it, select the framework in the Xcode project navigator and choose Show in Finder. Then clean and build your project.
This can also be caused if you're missing framework header files or a reference to them.
In that case, you should trying removing the SDK or framework and adding it again.
Good luck.
If you installed dependencies using CocoaPods, make sure you open your XCode project by clicking on your .xcworkspace file, and not the .xcodeproj file.
It seems like the project file may have been corrupted somehow.
The most sure way to fix this is to create a new project, and move your files and old info.plist over on top of it.
The next most likely way to fix this is to create a new target in your current project, and see if that will compile (if you have any special flags from the old target you'll want to copy them).
Also you could try compiling for Release vs. Build and if one of them works look at all of the compiler options and see what is different.
If you added a header search path for Sharekit, perhaps try clearing out the whole header search path and see if that fixes things. Also make sure your project is still including frameworks that a brand new project includes (UIKit and NSFoundation, possibly others).
Add the .m file to compile source page.
steps:-
clicking on he project in the navigation menu
select the target
select build phases
Select the + button and add the file in compile sources.
Hope that helps anyone with this problem
The problems are the spaces in your path:
xcode uses the following switch for the linker:
-F/Users/bbrandy95/Documents/Broken Brandsonic Web Projects/Brandsonic Web mobile/../../Downloads/0.2.1gm1/iphoneos4.0/System/Library/Frameworks
and since it is not quoted it won't work. ( It is looking for the folder "/Users/bbrandy95/Documents/Broken"
You should rename the directories, or look through the project settings and add quotes to the directories. (But this might be tricky to find)
I too had the same problem with 45 same kind errors, when I add the libxml2.dylib into my project the errors disappeared.
In some cases your library Search Path is empty.Because there are many Apple-mac-o linker errors.
See my answer also at.
Apple Mach-O Linker Error using Core Data classes in OCUnit
I had this issue, now for my circumstances selecting a more recent iOS version as the deployment target rectified this for me. My project was set to deploy to iOS 5 by default and changing this to 7 (the most recent) did the trick.
For anyone new to iOS development this can be done by clicking on your XCode project file in the navigator > deployment info > deployment target and selecting the appropriate version from the drop down menu.
I'm sceptical that this will solve some of the issues that others are having but there may be a few people out there in the same boat as me.
It's because the project inserted the core data's xcdatamodeld file in compile sources. Select your project -> Build Phases -> Compile Sources and delete projectName.xcdatamodeld file.
And also check if you have imported .m file instead of .h file, it also gives the same linker error. Check all the #import codes.
And check if you have added core data frame work in library and imported core data .h file. Check for creation of NSManagedObject and import it's file.
Just try it and reply me if still any error.
I had the same problem,
I just simply set the Build Option -> Enable Bitcode to NO
I faced this problem with my self developed cocoapod.
Error was: Apple Mach-O Linker errror
It turned out, that I had defined a protocol and implemented a protocol extension. One method of the protocol extension was public, but the protocol itself was not. And this caused the Apple Mach-O Linker error.
Example:
protocol MyProtocol { var field: String { get} }
extension MyProtocol { public func giveMeSomething() -> String }
public class MyClass: MyProtocol {}
In the description the error mentioned MyClass referenced from MyProtocol -> MyProtocol referenced from giveMeSomething()...
So, the solution was to make Myprotocol also public
Hope that helps someone.