Duplicate Symbol Error when Linking in Xcode: '_CRLF' | XCode 15.0 Beta 8

My app was working fine on XCode 14.6 and I was able to install it on my iPad.

For testing the app on my iPad on iOS 17 Beta, I updated both my iPad and XCode 14.6 to XCode 15 Beta 8.

Now when I am trying to install it, I get this error:

duplicate symbol '_CRLF' in:
    /Users/mac-0077/Desktop/HBook/eBook/Nov_2023/ebookapp copy/eBook/Third Party/PrinterLibrary/libPrinter_170b.a[arm64][4](ZPLPrinter.o)
    /Users/mac-0077/Desktop/HBook/eBook/Nov_2023/ebookapp copy/eBook/Third Party/PrinterLibrary/libPrinter_170b.a[arm64][3](CPCLPrinter.o)
ld: 1 duplicate symbols
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If I am installing the app using XCode 14.6 on the simulator(iOS 16), it's working.

If I am installing the app using XCode 15.0 beta 8 on the iPad(iOS 17 Beta), it's not working giving the above error.

I have tried many things but nothing worked.

Any help or guidance provided would be greatly appreciated. Thank you in advance for taking the time to assist me!

Answered by DTS Engineer in 764456022

Using -ld64 is a short-term workaround. To quote the Xcode 15 RC Release Notes:

The classic linker can still be explicitly requested using -ld64, and will be removed in a future release.

You need to get to the root cause of this problem, per the advice in my previous response.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I met this error too. When I used Beta 5, everything was good. but in Beta 8 I got the same error.

My best guess here is that you have two static libraries, libPrinter_170b.a and libPrinter_170b.a, that each define the CRLF global variable. That’s not allowed:

% cat test.c 
#include <stdio.h>

int main(int argc, char **argv) {
    fprintf(stdout, "Hello Cruel World!\n");
    return 0;
}
% cat libA.c 
extern const char * CRLF;
const char * CRLF = "\r\n";
% cat libB.c 
extern const char * CRLF;
const char * CRLF = "\r\n";
% clang test.c libA.c libB.c 
duplicate symbol '_CRLF' in:
    /var/folders/ts/89wlmlw971x8k8ds6y_48kn80000gp/T/libA-16a320.o
    /var/folders/ts/89wlmlw971x8k8ds6y_48kn80000gp/T/libB-a9829e.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Are you compiling these static libraries from source? If so, the easiest option is to define them using static.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

same issue here.

Accepted Answer

Fixed: Add "-ld64" under Build Setting -> Other Linker Flags

[https://developer.apple.com/forums/thread/731090]

Using -ld64 is a short-term workaround. To quote the Xcode 15 RC Release Notes:

The classic linker can still be explicitly requested using -ld64, and will be removed in a future release.

You need to get to the root cause of this problem, per the advice in my previous response.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo how should we do Mocks with this new linker then?

how should we do Mocks with this new linker then?

It’s hard to say without more context.

This is a much bigger issue than the one that covered by this thread, so I encourage you to open a new thread here with more details about what you’re doing and why it’s failing. Tag it with Linker so that I see it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Xcode Version 15.0 (15A240d) -ld64 has been declare an alias named -ld_classic

Duplicate Symbol Error when Linking in Xcode: '_CRLF' | XCode 15.0 Beta 8
 
 
Q