Linker can´t find symbols

Hello folks, I am new to MacOS/iOS and ran into the following problem (IDE is Xcode13): I have made a small c++ audio library with the Juce framework that I want to integrate into an existing application running on MacOS and iOS.

So far so good, I added the Projucer library project as a subproject to my workspace, added the correct header paths, added the subproject as a dependency and linked the library in the build settings of the target, so I can directly test changes I make to the library in the app (for now it is only a small c++ console app for testing since I wanted to find out how to correctly import the library before writing the bridge, as described here: https://github.com/adamski/audioengine-demo).

The problem I am currently running into is the following linker error I cant resolve:

Undefined symbols for architecture arm64:

ld: symbol(s) not found for architecture arm64

This error occurs 101 times, for every juce function that is beeing used. I checked the target architecture settings in both the library and the console app, they are the same. If I change the build active architecture only setting to No, the error changes to

ld: symbol(s) not found for architecture x86_64

I analysed the library binary with the file command in the console, which led to following output:

mylib.a : Mach-O universal binary with 2 architectures: [arm64:current ar archivecurrent ar archive] [x86_64]

mylib.a (for architecture arm64): current ar archive

mylib.a (for architecture x86_64): current ar archive

In my understanding, the binary should support my architecture (arm64), so why cant the linker find the symbols?

Thanks for your help!

I suspect that the architecture stuff is a red herring. If you had an architecture mismatch, you’d get a different error (the linker would be complaining that it couldn’t find the architecture in your library file).

The most common cause of problems like this is C++ name mangling. Folks implement a library in C++ without added extern "C" { … } and then try to call it from C (or Objective-C). C++ uses a mangled symbol and C uses a nonmangled one, and you get a link error.

However, I’m not sure that’s the case here because you’re trying to use the library from a C++ client, and so both sides should mangle the same way.

What sort of library is it? Static (.a)? Or dynamic (typically .dylib)? If you’re not sure, run the file command-line tool against the library and see what it prints.


Oh, one last thing: You tagged your question with both iOS and macOS. Be aware that these are different platforms, and the platform matters when it comes to building library code. For example:

  • Intel code built for the iOS simulator is not the same as Intel code built for the Mac.

  • Arm code built for iOS is not the same as Arm code for an Apple silicon Mac.

Make sure you’re not mixing your platforms.

Share and Enjoy

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

Linker can´t find symbols
 
 
Q