I usually work a lot with Objective-C and sometimes I do have multiple files that represent multiple classes.
Sometimes program run and sometimes I get this error:
linker command failed with exit code 1 (use -v to see invocation)
What is the reason for this error? There were different solutions reported in the forum but I want to understand what is the reason to avoid.
The general idea of compiling a program consists of separately compiling each file, and then linking the compiled binaries together. When it says linker command failed it means linking the binaries failed. What the linker error is depends on what the error says. Usually inside the junk there are a couple useful lines that can help you figure out what the issue is. A couple that comes to mind is when a function is defined twice, when a function is called but isn't declared anywhere, or when you import a library that contains a main function (which means main is defined twice) etc.
There are a lot of possible reasons behind this. I list some of those that I experienced.
You accidentally imported a .m file inside a .m file.
The libraries you linked have the same class name and it will cause a conflict.
The libraries you linked are built with different settings(e.g. the target iOS version, code signing, etc.)
The libraries you linked are built for simulator then you used it on a real device.
You forgot to put a semicolon in the end of a declaration in Localizable.strings
Related
When I'm writing simple code in ViewController, I wanted to run it and boom. Apple Mach-O linker error as shown. I don't know what is the problem. Then, I've made a quick research, according to research; I deleted Derived Data folder, I deleted Derived Data folder contents, I deleted test hosts in build settings(it is already empty), I cleaned the build folder and I applied clean action. But nothing changed same errors. Is there any specific solution of this error depends on app and what is that solution?
EDIT:
I moved the codes to a new xode project and I noticed that when I add the line let ftp = CkoFtp2(), the error occurs otherwise it compiles. But it is coloring the CkoFtp() part of line and I'm not getting any specific errors there. Just Match-O and linker command.You can see the CkoFtp2 code here.
I had the same issue. Please make sure to follow the directions on chilkat's site, particularly the following:
Add libChilkatCocoa.a to your list of libs for linking. In your project build settings, find Build Phases, Link Binary with Libraries, select Add Other, navigate to the libChilkatCocoa.a, and add it.
The Chilkat library internals are written in C++. Therefore, your Swift application will need to link against the C++ runtime libraries. In your Build Settings, go to the Linking section and add -lstdc++ to the Other Linker Flags.
https://www.chilkatsoft.com/chilkatSwiftCocoa.asp
I also ran into trouble because the libChilkatCocoa.a library resided in a folder that had a space in its name. Avoid that, or make sure it is correctly escaped under Build Settings.
Looks like you've got a reference to a framework located in your Downloads folder. Chances are you moved that somewhere else, yes? Remove the SimpleUnzipper framework from the project and re-add it from wherever you moved it to.
After the edits, this is clearly not the problem...
It's hard to tell from just the error message, but it appears that you're using a library that you downloaded from another developer. Are you sure you followed their instructions for setting things up? The linker error means that you're not linking your program with the library, though it looks like you've managed to set up a bridging header so that you can call the function without getting a compiler error.
I have used OA consumer class in my app and while trying to run it i got this error and i dint understand the problem. i have added -ObjC to other linker flags also. i have searched google but dint find any related to this. I have disabled the arc and do i need to add any linker flags or is there any other problem.
can you please tell me whether there is an error in code or do i have to change the linker settings
These are linker errors -- it's finding the headers just fine, but the library is missing at link time. Make sure the OA library is in the Linked Frameworks and Libraries list for your target.
I removed this error after lots of trails, the problem in my case is the corefoundation framework is corrupted, it has shown a small question mark on it, after i carefully read the exception, it says that some files are missing from the corefoundation framework, then i removed the framework and copied a new one from another project then the errors gone.
Note: while you are removing any file, don't just remove references , move it to trash, other wise the Xcode may give you a error file already exist and cannot be copied.
I am trying to integrate PSPDFKit for iOS in my project and I have not been yet able to success. After downloading the Demo version, adding the framework to my project, adding all the required libraries and placing
#import <PSPDFKit/PSPDFKit.h>
on the 'prefix' file, I get an linker error:
ld: section __objc_const (address=0x00613EA8, size=4651232504) would make the output executable exceed available address range for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
NOTE: My project uses PSTCollectionView and I have successfully compiled PSPDFKit on a test project (created only for that effect).
I would really appreciate any help. Thanks in advance.
Apparently, you have too many included files in your PCH file.
Try removing some of them, and include those files only where you need them, not globally.
As far as I understand it, this is a bug in Apple's compiler/linker chain. Please file a radar at radar.apple.com with your failing project. A workaround is to use the source code as a subproject instead of the precompiled binary.
As soon as I can get my hands on such a project, I can experiment with the settings to see if there's any workaround. Seems to only happen under very specific combinations with other 3rd party code.
I'm trying to build Assimp for iOS, it compiles fine, with no errors, however, when I try to use it in my project I get a lot of errors (154 to be exact) during linking. Judging after the method signatures, the errors are C++ related, however, I would like to use the C interface. I've tested with lipo and the library is compiled for my arch, it's actually a fat library. They are linker errors, should be easy to fix, alas, my lack of experience doesn't help. Here is a screenshot with the errors (first rows, as there are more than 100 in total).
How should I debug this? What went wrong?
EDIT: Thanks to #Zadr I managed to narrow it down to 8 errors:
_crc32 sounds very familiar, but still can't find the reason behind all this.
The library you're building was linked against one version of libstdc++, and you're trying to link against a different version.
In the project settings, there should be a "C++ standard library" field. Change that from the default option (clang's libc++, iirc) to the other option (gcc's).
In addition to what #zadr has already mentioned, you should also link libz.dylib for the last 8 errors to go away. I'm almost certain those functions are related with it and I know for sure Assimp uses libz.
First Tell Me if You have to Putted any framework as copy-paste ?? in most of cases this type of issue created.
Generally this Types of Error Occur when your class .m file is not store/putted under Compile Sources
In This case you need to add manually this .m file to Compile Sources
Following step Describe how to put .m file in Compile Sources manually
Select Project Form Project Manager
|
|
Targets
|
|
Build Phases
|
|
Compile Sources
|
|
Click on '+' button and add .m file in it
This is Step For how to put file manually in Compile Sources.
I recently just upgraded to the new XCode. After I upgraded, some of my apps won't build. I get this error:
ld: cannot link directly with /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/system/libcommonCrypto.dylib. Link against the umbrella framework 'System.framework' instead. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've tried everything - cleaning, reimporting, changing architectures...
Please help
I resolved this issue in a diffent way after I tried both the above where neither worked for me.
The problem was that when I was adding the library from the main interface (main build-settings...etc) I was searching initially for crypto and then two libs comes back libcorecrypto.dylib and liblibcommonCrypto.dylib, if you notice, both exists in gray-color unlike the usually yello-colored libs that you normally add. Adding these causes the compiler to report back (some other libs are missing, such as the libz, or another lib that will be needed the more functions you take on.
If you notice the above two libs would normally sit under JavaScriptCore.framework library (which is the yellow one), therefore, by removing the above two and adding JavaScriptCore.framework instead, the problem was resolved, and build successful showed
Also to mention that based on the gray-libs existing as a bundle inside JavaScriptCore.framework, the libcrypto and the other one will not exists under the /Library/.../system/path as mentioned above, i.e. you didn't delete them from your system, they're just not there.
Again, the solution is:
*From your main XCODE project settings, don't add:*dd
libcorecrypto.dylib
liblibcommonCrypto.dylib
Instead, add:
JavaScriptCore.framework
In your .m (code), just source them normally by doing:
#include <CommonCrypto/CommonDigest.h> (or any of your other libs as needed in code)...
It should work fine.
I hope this helps.
Kind Regards
I just solved this as follows:
It turns out that the libcommonCrypto.dylib error was a red herring.
After removing libcommonCrypto.dylib as suggested above, I got 9 new errors.
At first glance, I assumed they were Crypto errors, but in fact they were not; for me, it actually traced back to zLib not being included, which was "imported" in a deeper part of the overall implementation (of which crypto is a part).
For me specifically, it traced back to ASIDataDecompressor.h, #import < zlib.h>
I fixed it by including the missing libz.dylib framework; ultimately, I did not have to explicitly include libcommonCrypto.dylib.
So, be sure to check the errors closely after toggling libcommonCrypto, and make sure some OTHER libraries are not missing, instead.
I'm using cocoapods for library management. One of the libraries (you can simple search in your workspace) contained reference to CommonCrypto.framework which was red in the list of frameworks in its project settings.
In my case I had to remove the dependency on CommonCrypto.framework, but this solution lasts just to another update of your pods.
Btw I'd like to know a command to list the graph of dependencies among the libraries in the Podfile.
I had the same error,
ld: in '/usr/lib/system/libcommonCrypto.dylib', missing required architecture arm64 in file /usr/lib/system/libcommonCrypto.dylib (2 slices) for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I solved this problem by checking my $PATH. It was a missing file.
Using find / -type f -name libcommonCrypto.dylib
Comparing my libs with my friends mac systems, it shows that this file was not present on my computer :
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/system/libcommonCrypto.dylib
Xcode using $PATH fallback on /usr/lib/system/libcommonCrypto.dylib but it's not the good built (i386 insteadof arm stuff).
I copied the version of my friend, move in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/system/ and then I was able to build my projects again.
There is a vicious problem here cause there is a lot same file for this lib depending of your architecture and most of them are not intended to be used for ios builds. But the $PATH env var will fallback on /usr/lib when no files are found on dedicated dirs.
Xcode fallback on /usr/lib/system/libcommonCrypto.dylib but this is definitely not the correct lib cause it not a built for ios, but a built for my mac.
Better Solution ,as it says remove libcommonCrypto.dylib,and replace by adding SystemConfiguration.framework.It worked for me,might be useful to someone.I was getting Linker Error saying gettingLink against the umbrella framework 'System.framework' instead.