Linking External Libraries When Exporting JUCE Projects into Xcode
Tags: tutorial, cpp, todayilearned, juce
Published: 2022-07-19 19:57:00

[JUCE](https://juce.com/) 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](https://github.com/curl/curl) and [base64](https://github.com/tobiaslocker/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](https://docs.dolby.io/media-apis/docs) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7hkh2gjlsvreql1kvl7.png)


### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wtp10edopdj2ctzsi67w.png)


## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hna63k3ekmjuambkigq9.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7y18j6suljy6ioh1fvia.gif)

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'](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ye8eirx4r83may5rmu4x.png)


## 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'](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xdurac9ptfwtozvv8zlz.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0nbj961qvcmh4gq9g3iy.png)

![Xcode build settings for a project showing the header search paths specified earlier made it into Ccode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3orxrksph7egin4vw43y.png)
  

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](https://dolby.io/blog/enhancing-podcast-audio-using-dolby-io-zapier-and-onedrive/) or hear more about [how the API works from a Sr. Staff Researcher at Dolby.io](https://dolby.io/blog/building-a-speech-enhancement-chain/).

Happy external library linking!