DEV Community

Cover image for Linking External Libraries When Exporting JUCE Projects into Xcode
E. Bennett for Dolby.io

Posted on • Edited on

Linking External Libraries When Exporting JUCE Projects into Xcode

JUCE is a powerful tool for building audio plug-ins for digital audio workstations (DAWs). Included in the JUCE library once it's downloaded is the Projucer, which is a project management tool. Through the Projucer, developers are able to easily export their code to a variety of integrated development environments (IDEs) for building and deploying their applications. When doing so, however, developers need to be aware that the process of linking external libraries with the Projucer is different than when using an IDE alone.

I discovered this the hard way. I decided to use the Projucer to export my audio plug-in project into Xcode. While trying to link curl for cpp and base64 into my project, I found it wouldn't build! I needed to link both of these libraries to be able to use Dolby.io's Media APIs within a C++ environment. At first, I tried to add the build instructions directly into Xcode, but I found that the settings were not saving each time I launched my project, that's when I found out the Projucer handles all the build instructions for you.

Keep learning to learn how to link external libraries into an exporter like Xcode using the Projucer!

Using IDEs as Exporters in The Projucer

The first step is to make sure the IDE you want to use is added as an available exporter in the Projucer. I will focus on using Xcode, as it is the IDE I use, but there are several other options including Visual Studio.

Adding Exporters to A New JUCE Project

For new projects, check off the IDE(s) you will be using with JUCE in the settings menu before you create the project.

New Projucer Project showing how to add new exporters in the main settings menu

Adding Exporters to Existing JUCE Projects

For existing projects, open your project in the Projucer and navigate to the 'Exporters' sidebar. From there, select the plus sign at the bottom to add your preferred IDE. All the settings to link external libraries should be the same for all the different IDEs available, but I've only tested this process with Xcode for MacOS so far.

Existing projucer project is open. User can click on a plus sign near the bottom of the page to add new exporters

Exporter Build Settings

Once you've added your desired IDE, click on its name in the 'Exporter' sidebar. The resulting menu on the right allows developers to adjust the build settings of the project once it is exported (among other things). Shown below is the menu for Xcode MacOS.

Projucer project exporter menu for Xcode showing various build settings that are available

From here, you can add compiler flags, linker flags, external libraries to link, etc.

Now that the exporter is set up - let's start linking libraries.

Header Search Paths for External Libraries

First, you need to add the file paths to the external libraries you need to link.

1) Go to the 'Exporter' tab and click on 'Debug'
2) In the 'Header Search Paths' text box either type the full file path or drag and drop the file in to paste the file path To add multiple paths just add a new line between them

gif showing a file being dragged into the projucer and pasting the file path of the file

3) Repeat step 2 on the 'Release' tab as well

Projucer Exporter Release menu shows the file paths of several directories written into a text box labelled 'Header Search Paths'

Specify Build Linker Flags in The Projucer

Some libraries, curl included, require linker flags to build properly with your projects. This is also handled by the Projucer.

1) Click on the name of your exporter
2) In the textbox labelled 'Extra Linker Flags,' write the flags you need. For curl, the flag is '-lcurl'

Xcode exporter menu in Projucer shows '-lcurl' has been written into the textbox labelled 'Extra Linker Flags'

Check Build Settings in Xcode

Now, hit the export button at the top of the screen to open your project in your desired IDE. If you are using Xcode, like I am, you will be able to see the linker flags as well as the header search paths that you added in the project build settings.

Xcode build settings for a project showing the linker flag specified earlier, '-lcurl', made it into Ccode

Xcode build settings for a project showing the header search paths specified earlier made it into Ccode

It is important to note that the reason we don't have to manually add these build settings each time we use our IDE is because of the Projucer. If you tried to simply add these settings directly to your IDE of choice, it would not save into the exporter, and you would have to manually add them each time.

Conclusions

And there you have it! Now that your project build settings have been adjusted in the Projucer, they will launch in your IDE everytime you export your project to work. Now that I have curl and base64 working, I have been integrating Dolby.io's Enhance API into JUCE to build an audio plugin.

If you are interested in learning more about the enhance API check out how you can use it without having to write any code with Zapier or hear more about how the API works from a Sr. Staff Researcher at Dolby.io.

Happy external library linking!

Top comments (0)