Problems linking static library


Hi all, I’m having an issue trying to link a static library in Juce. I’ve managed to get it working in core C++ (XCode) by adding the Accelerate, CoreAudio, and CoreAudioKit frameworks along with my lib in the build phases setting in XCode, then bringing the lib and it’s corresponding .h into the file explorer.

I tried to repeat this process in Juce (and even tried doing the same process alone in XCode, knowing it won’t save) and I still get linker errors. I tried linking it using the extra compiler flags and linker flags, the external libraries to link, and extra library search paths. In short I’ve tried everything…

Wondering if there’s anyone that can help? Much appreciated!


For me it works like that:

  • additional include flags: -Ipath/to/include
  • additional linker flags: -Lpath/to/lib
  • external libraries to link: name without .a .so or .lib, the projucer will add that




Hey Daniel, thanks for your help. Unfortunately it’s still not working for me. Here’s what I have:

Here’s the lib itself:

Here’s how I’ve set it up in the Projucer:

Still not finding the lib:

Thanks for your help!


Yeah, the linker has it’s own search path, and it is fed by -L as linker flag. You can see it in the linker call e.g. -L/Users/djatwar/Development/JUCE/ScratchEZ/scratchGameCPP/Builds/MacOSX/build/Debug

Option 1: quick and dirty copy the lib there (bad idea, because no manual steps should be necessary in the build folder, but works)
Option 2: add the path to the libVinylTrack.a file with -L in Extra linker flags. You can add any number of paths using -L for each folder

It is a bit tricky though to get the relative paths right, that’s why I use something like -L${PROJECT_DIR}/../SDK. If you use simply relative paths, I think it is relative to the xcodeproj file IIRC.

I just notice you use round brackets for PROJECT_DIR, I think there should be curly brackets.

Good luck


Thanks. I’ve got the relative path right with -L in extra linker flags, but it’s still saying that it hasn’t found the library. So strange!

Is it possible that I need to somehow add the coreaudiokit framework again to make this work, as I did before when I got it working in core c++?


Ok, two more checks:

  • does the correct path appear in the call to the linker? It could be, that some type error, or Projucer save sequence was not 100%
  • add -static to the extra linker flags. I thought it would try that automatically, if no .so was found, but maybe you need to say explicitly, that you want a static link…

If your library depends on coreaudiokit, then yes. But that would have been unresolved symbols later on. At the moment the linker doesn’t see your libVinylTrack.a

Oh, I just see: don’t put libVinylTrack into the libraries to link. The prefix lib is also automatically added, just put VinylTrack and the linker will search for and if not found for libVinylTrack.a. When using the -static it will search for the .a only (or prefer .a? IDK)


It works!!! You were right I just had to take “lib” off the front of the name. Didn’t need to use -static. Thanks again Daniel :smiley: