Linker command failed with exit code 1 (duplicate symbol) - xcode

I developing a game in Unity and I have used Admob, Facebook and GameCenter in it. It was working fine on iOS until I have added the OpenIAB for in-app purchase, though it works fine in Unity Editor.
I am getting this error in xcode:
duplicate symbol __Z14MakeStringCopyPKc in:
/Users/UmerAzeem/Library/Developer/Xcode/DerivedData/Unity-iPhone-ejwaywhkiokzjofdpwnbebkbleai/Build/Intermediates/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/armv7/FBUnityUtility.o
/Users/UmerAzeem/Library/Developer/Xcode/DerivedData/Unity-iPhone-ejwaywhkiokzjofdpwnbebkbleai/Build/Intermediates/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/armv7/AppStoreDelegate.o
ld: 1 duplicate symbol for architecture armv7 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
See error screenshot here
I have tried almost all the solution that I could find over the internet, but still don't understand how can I remove this duplication error, I have tried looking for duplicate files too, but it also went in vain, someone help me out of this, would appreciate it.
Thanks.

Look up in your project for:
MakeStringCopy
And make sure it exists (if exists) only once. If it appears more then once, rename one (make sure to rename it where it being called as well) and try to build again.

I have recently face the same issue. I know Umer Azeem got the answer but to help someone else who may suffer from the same issue I was in.
According to my application flow I am using printer related third party class to print. To use that I have created object of that class in both of my files ImagePrintViewController and PrintResultViewController separately and passed required data to it.
In my scenario I am getting same error with variable name like _printerSetup in two of my files/Library/Developer/Xcode/DerivedData/../x86_64/ImagePrintViewController.o
and /Library/Developer/Xcode/DerivedData/../x86_64/PrintResultViewController.o.
I have search in both of my file for the above variable name. But I couldn't find that.
After searching long on this I got a idea to delete reference of my second file i.e. BRPrintResultViewController.h and BRPrintResultViewController.m after merging code in my first file.
With this I found my solution and my code runs fine after this.

Related

Why does Xcode mismatch Target membership?

I have been creating an entire plethora of c++ syntax to help beginners. I use Xcode as my primary IDE. I tried running a program in "function" target but it keeps showing this error.
duplicate symbol _main in:
/Users/xivya/Library/Developer/Xcode/DerivedData/parentcpp-afpbdfpaaxeerfdalgncgzpkuaqt/Build/Intermediates.noindex/parentcpp.build/Debug/function.build/Objects-normal/x86_64/manipulator.o
/Users/xivya/Library/Developer/Xcode/DerivedData/parentcpp-afpbdfpaaxeerfdalgncgzpkuaqt/Build/Intermediates.noindex/parentcpp.build/Debug/function.build/Objects-normal/x86_64/pattern_program.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have selected "function" target from top-left, see image -
But at mid-right of the screen "array" target is selected under "Target membership". It selects itself automatically. Whenever I change my target to anything else no error happens. Any and all help will be highly appreciated!
I will divide the answer into two categories.
> Hunting down the issues
Whenever you've multiple targets lurking into your project structure, it may invoke the same error if you ignore just one thing. Suppose, you ran a target and wish to run some different target now. It's obvious that you will change the active scheme from the top-left. More obvious that you will choose the corresponding Build Phases BUT one might miss a minute option to change the target from "select a project or target" option lurking at that instance. If you didn't get me please, read it again or see these pictures.
There is nothing wrong here. pointers target has been selected and reference.cpp execute without any issue.
Now, what if we chose to run a different target? We will do all the customary things required.
We chose function target and in Build Phases we chose the required file. What we miss to observe is that pointers target is still been selected and Xcode hasn't changed it.
That creates a problem which leads to errors like this:
A possible error that can be displayed if one misses changing the target at a different instance, where Xcode should already have changed the target but has not.
Please keep those small things in mind.
> Meaning of error
Most of the times one might encounter "duplicate...etc.." type error. This may roughly mean that Xcode is not sure as to which target to run, as you might have forgotten to change the target at a different instance, probably in Build Phases pannel.

opp_run error on omnetpp IDE

I'm working on a veins project at the moment and everything went fine till today.
I had the need to add a new module to the ' veins/src/veins/modules ' directory so I simply created a new folder and put some .ned files and relative header/source files in there. I got some errors after doing that but nothing special (I was probably doing something wrong and compiler didn't like it). I then decided to delete the folder and try again maybe the day after.
After doing so I re-run the same exact simulation and omnet/IDE started showing this, not being able to launch:
<!> Error: Cannot load library '../../src//libveins.so': ../../src//libveins.so: undefined symbol: _ZN8Flooding6finishEv
End.
Simulation terminated with exit code: 1
I've tryed a fresh clean and rebuilt the whole veins project but that didn't help.
I googled this error but couldn't find anything similiar to my case.
Thanks in advance for your help.
Best regards.
c++filt _ZN8Flooding6finishEv shows that the missing symbol is
Flooding::finish(). It seems that you have a deceleration of this
method but missing a corresponding implementation. I'd assume your
module was called Flooding and you did not delete all of it when
starting over.
Julian Heinovski
Running the same configuration on Windows showed that it was indeed Flooding::finish() not implemented (that's probably because it's automatically demangled on Windows). I just deleted the declaration and solved my little inattention.

XCode 7 / Cordova plugin / Link issue: _utf8_nextCharSafeBody undefined symbol

I'm adapting an (apparently outdated) Cordova plugin for use in my app (PhoneRTC if you're curious).
As a Linux/CLI guy at heart I've been struggling with XCode for a day, and I managed to iron out most of the deprecated code using a lot of Google and some blind guessing. However, now I'm stuck with a final error during the linking phase:
"Undefined symbols for architechture arm64: "_utf8_nextCharSafeBody", referenced from: [snip]"
The plugin's original installation instructions mention linking the binary to the library libicucore.dylib, but this seems to have been removed in the latest XCode (there are references of the same name with .tbh extensions available but these aren't valid for that dialog - even though I can select them, but whatever).
Some more Googling offered suggestions for linking various *.frameworks instead, but to no avail - the error remains.
Does anyone have any idea what I need to link to to make this function available? Or if it's permanently removed I'd also like to know, although that would involve rebuilding the binaries which wouldn't be something I'm looking forward to...
Or if you don't know, would there be a way to grep through Apple's libraries somehow to see which one is supposed to be defining a missing symbol?
(Needless to say, IF I can get this working it's going to be forked from the original repo and donated back to the community :))
So, I'm not sure what I changed exactly, but suddenly I could add libicucore.tbh as a linked library. I probably changed the build target or something, but in any case the linking error disappeared (to be replaced by a signing error because XCode, but that I can solve).

unable to print object ('po') in xcode6 beta 6 osx swift project: (Error in auto-import: failed to get module '__ObjC' from AST context)

An attempt to print object (po command) in xcode 6 beta 6 OSX Swift project results in this error message:
(lldb) po managedObject
error: Error in auto-import:
failed to get module '__ObjC' from AST context
In this case the object in question is an instance of NSManagedObject.
Any advice on how to help auto-import in getting __ObjC module into LLVM Abstract Syntax Tree context?
As of Xcode 6.1 if you attempt the po command twice it will work on the second attempt. The first po command will always fail for each new debugging session but subsequent calls work.
Have same issue in xcode 7.3.1:
error: Error in auto-import:
failed to get module 'Touch' from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2/libxml/tree.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2/libxml/tree.h:17:10: error: 'libxml/xmlversion.h' file not found
#include <libxml/xmlversion.h>
^
could not build Objective-C module 'LibXML2'
But you can use fr v managedObject instead of po managedObject.
I'd recommend double-checking that you have the
-D DEBUG
flag set under 'Other Swift Flags' for the scheme that you're using to debug. I experienced similar issues when I'd accidentally deleted it.
A clean of my project and deleting DerivedData worked for me.
I discussed a similar error message with an Apple engineer at WWDC2017. It seems like this issue can have many causes, and I am aware that mine is slightly different than the one described above.
My team spent weeks trying to figure this out, and it ended up being a bug on Apple's compiler, which we could never have figured out by ourselves. Also, it has a VERY easy workaround.
So, this is just me posting the fix here, in order to maximize the probability that someone else does a search for this confusing error message, and finds this answer.
So, here it is. In our case, we had an Objective-C project using a mix of Swift and Objective-C frameworks. This fix might apply in slightly different contexts, just try it.
There happens to be a bug with the way the compiling flags get aggregated from the frameworks and the project, and the "pure Objective-C" project "activates" it.
Solution: add one single, empty Swift file ("Whatever.swift", or whatever) in your Objective-C project, making it not-pure-objective-c any more (new->file->Swift file, don't create the bridging header. The file will only contain the import of Foundation).

WDL-OL: resource not found

i'm trying to build a simple Audio plugin using WDL-OL (a library that helps porting the plugin on various platforms) on OSX. The plugin builds ok on Windows
as soon as it tries to load a resource background file, i got an ASSERT warning that the file isn't found
1 my files are present in the Copy Bundle Resources part
2 i've tried all kind of combinations with/without subfolder, with caps or not
i'm lost there i don't get why it doesn't find the file
if i create a simple test it works, it finds the file knob.png but with my project it doesn't work
also if i point to the file knob.png (that should work), it doesn't work in my new project, so my guess is that it isn't the png files that are wrong. It comes from somewhere else...
here is what i used in the resource.h:
#define BCKG_ID 102
#define BCKG_FN "resources/img/background2.png"
and i call the background using this code :
pGraphics->AttachBackground(BCKG_ID, BCKG_FN);
please help, thanks
Jeff
EDIt1 : okay i found something interesting
in MyProject-OSXAPP-Info.plist, "Bundle Identifier" is set to : com.Khaelis.standalone.${BINARY_NAME}
but if i stop the program at the function LoadImgFromResourceOSX(...) and look at the variable "bundleID", it shows:
"bundleID = com.Khaelis.standalone.test"
even if i entered another BINARY_NAME (in MyProject.xcconfig)
how come ? the compiler doesn't apply the name i put.
the variable "bundleID" should be com.Khaelis.standalone.PerfectEQ not com.Khaelis.standalone.test
is there a file that i should update?
ok found it
if you ever encounter this kind of error (resource not found) check if the Bundle Name (in resource.h) and BINARY_NAME (in Project.xcconfig) are the same
then it should work
Jeff

Resources