Linking against a static library with Projucer and Xcode?

I have a desktop JUCE app that needs to make use of libzippp on both macOS and Windows. I downloaded the library and ran the cmake commands to compile and install everything as per the readme.
This project already uses Keyzy as a static library so I assumed that libzippp could be added the same way, adding ../../libzippp/src to the header search paths and ../../libzippp/build to the extra library search paths for both debug and release configurations in the Xcode exporter.
In “Extra Libraries to link” I’ve tried building with libzippp, libzippp_static, and zippp_static and the static library file is called libzippp_static.a (for Keyzy, I use the string KeyzyClient and the library file is called libKeyzyClient.a)
In Xcode, the editor auto-completes functions and types from libzippp and shows quick help from the library when hovering, but when trying to build it fails with a “Library not found for -llibzippp_static” error message.
Since the header file and the static library file are both present, I assume this might be a linker issue? Is there something I need to add to the “Extra Linker flags” field to make it work? Any help or advice appreciated!

You’ll have to forgive me if this doesn’t work; the project I’ve been working on for three years started out with one part of it being a static library that was linked into the other part, before I made a JUCE module out of it and dumped that approach. That was awhile ago.

But checking my notes, what I used to have to do, in the Projucer Xcode Exporter:

In “Extra Linker Flags”:

-L../../folderContainingTheLib

This is a path to the directory containing the lib, relative to the main Xcode project (file that is generated by Projucer).

Then in “External Libraries to Link” section, you would put (example):

MyLibrary

(note that the library file is actually named libMyLibrary.a, but you leave off ‘lib’ and ‘a’). I don’t remember why, but that is what used to work for me.

So in your case, I guess that would be zippp_static .

Another caveat: my static library was created with a separate Projucer Static Library project… may not matter…

EDIT: here, I dug up an old link where I think I got some help. Good luck!

1 Like

Thanks! I did need to use zippp_static and include the underlying zip library, but it does build correctly

1 Like