I am facing duplicate symbols issue during use of Core plot API and ESRI map Arc GIS API.
In my app I am using Core plot and ArcGIS API. To provide support for 64 bit device, I have download new API for ArcGI (ESRI map) and accordingly update CorePlot API for 64 bit. After making changes I am facing issue:
error description are here:
duplicate symbol _squareOfDistanceBetweenPoints in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTUtilities.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(CPTUtilities.o)
duplicate symbol _niceNum in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTAxis.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(CPTAxis.o)
duplicate symbol _CreateRoundedRectPath in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTPathExtensions.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(CPTPathExtensions.o)
duplicate symbol _AddRoundedRectPath in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTPathExtensions.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(CPTPathExtensions.o)
duplicate symbol _MyCGPathApplierFunc in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(NSCoderExtensions.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(NSCoderExtensions.o)
ld: 5 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If anyone face issue please suggest. I am unable to figure out what is duplicate in those API Earlier these two working fine (OLD api without 64 bit support)
You might have imported the .m instead of the .h file
You might have added any Typedef function in .H file and have imported .H in many classes.
In my case it was an issue,
ShadowASettings ShadowSettingsMake(CGSize shadowSize, CGFloat shadowOpacity, CGFloat shadowRadius){
ShadowASettings settings;
settings.shadowOffset = shadowSize;
settings.shadowOpacity = shadowOpacity;
settings.shadowRadius = shadowRadius;
return settings;
}
I wrote this function in ABC.h
and then I imported ANC.h in my HomeVC.h and XYZ.h
So, then I simply move this function to .m of that class as it was only used in .m
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'm using paho MQTT library in my project.
And when I build the project on simulator , I got the following errors.
duplicate symbol _client_version_eye in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTClient.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTAsync.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTAsync.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTProtocolClient.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/Socket.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPersistence.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/Thread.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTProtocolOut.o
ld: 25 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
MQTTClient.c and MQTTAsync.c should not be included in the same project. They are used to build different libraries. Decide whether you want the blocking or async behaviour and use that file.
Try it....
The error may occur when you copy and paste the contents of one file to another file with its interface name which means two classes with same interface name.
In your code you have two different files with the same Interface name.
The problem is most likely due to a typo when including the header.
Check so that the header file (.h) is included and not the implementation file (.m).
Also Clean your project and build folder sometimes it will also solve this error
Also delete the derived data.
My app was working fine but after some modification I am getting following error please help me ......
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.nameLabel1 in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu- bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.phoneLabel1 in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu-bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController-D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.emailLabel1 in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu-bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug-iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController-D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.photoView1 in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu- bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.imageVC in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu- bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.dataObject in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu-bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug-iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController-D5D149C1AA17C975.o
duplicate symbol _OBJC_CLASS_$_MBThirdViewController in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu-bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
duplicate symbol _OBJC_METACLASS_$_MBThirdViewController in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu- bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Go to Build Setting and search for No Common Blocks and set it NO. And build again you will not get this error again.
Make sure that the ViewController is not added twice in your project.
OR
you have declared same variable more than once.
Also got to Xcode->Window->Organizer->Projects
And Delete derived data
Hope that might help.
check if this MBThirdViewController is added twice in your project.
OR
remove the reference to it and try adding it again to your project.
I gone through question already asked on forum. Getting error as below
ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
More error description is below
ld: warning: directory not found for option '-L/Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib'
ld: warning: directory not found for option '-Lrestkit'
ld: warning: ignoring file /Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib restkit/libRestKit.a, missing required architecture i386 in file /Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib restkit/libRestKit.a (2 slices)
duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kReachabilityChangedNotification in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kInternetConnection in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kLocalWiFiConnection in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_IVAR_$_Reachability.key_ in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_CLASS_$_Reachability in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_METACLASS_$_Reachability in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kConnectionDown in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have project structure like
Application
Static library A
Static library B
Situation
1) Static library A depend on static library B. The project A require Reachability check.
2) Added static library A into Application project
3) When I compile,getting linker error
Please help to resolve this issue.
If this solution is not working then check this..
Another reason this error often happens is accidentally importing the .m file instead of the .h.
Steps:
1.Check Build phases in Target settings.
2.Check if any file exists twice or once.
3.If file exist twice delete one. If not delete file in the bottom which is the latest one.
4.Build again.
You have Reachability class in libPOSNirvanaUtils.a & your Application and you are using libPOSNirvanaUtils.a in your application. So now your application has 2 reference of Reachability class.
If you are building libPOSNirvanaUtils.a then you can solve this with 2 ways:
Remove Reachability class membership from target libPOSNirvanaUtils.a
Add Reachability class in Copy files, remove Reachability class reference from your Application and use same class reference from libPOSNirvanaUtils.
I had the same problem while using prepareforsegue delegate. It turns out, I accidentally imported the .m file instead of the .h file. This will fix it. Look at your #import statements before you go crazy adding and deleting frameworks.
In my case I got this error because had the same named variables declared in several files in implementation part.
#implementation A
int a;
...
#implementation B
int a;
...
gave me "duplicate symbol _a ..."
Got a strange issue from Xcode, there aren't code issues and I haven't any idea how to handle with this problem. I also used Google and saw similar questions but the answers weren't useful for me.
duplicate symbol _OBJC_IVAR_$_Level._name in:
..../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build /Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
/Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
duplicate symbol _OBJC_IVAR_$_Level._type in:
...../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
...../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
duplicate symbol _OBJC_IVAR_$_Level._binaryImage in:
...../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
..../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
duplicate symbol _OBJC_CLASS_$_Level in:
..../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
... ../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
duplicate symbol _OBJC_METACLASS_$_Level in:
...Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
......Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
ld: 5 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
From what I've read there are many different reasons for this problem and therefore many different solutions but maybe someone will have done the same stupid thing as me and this will help them. I am fairly certain this is not the problem the OP experienced though as my duplicate symbols were in differently named .o files.
Basically be very careful with autocorrect when typing your #import statements. I accidentally imported the .m file instead of the proper .h file and ended up with output similar to what the OP has posted.
Hope this helps somebody!