# How to add a JUCE-built static library into another Projucer project?

**URL:** <https://forum.juce.com/t/how-to-add-a-juce-built-static-library-into-another-projucer-project/39060>\
**Category:** General JUCE discussion\
**Created:** [April 28, 2020, 1:10am UTC](https://forum.juce.com/t/how-to-add-a-juce-built-static-library-into-another-projucer-project/39060 "2020-04-28T01:10:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephenk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stephenk/32/15198_2.png) [@stephenk](https://forum.juce.com/u/stephenk)\
**Post date:** [April 28, 2020, 1:10am UTC](https://forum.juce.com/t/how-to-add-a-juce-built-static-library-into-another-projucer-project/39060/1 "2020-04-28T01:10:20Z")

</div>

Working with Mac OS X and Xcode, JUCE 5.4.7.

I have a GUI app and plugin projects that refer to some common code, so I wanted to put the common code into a static library.

I created a new static library project in Projucer, added the source code, opened it in Xcode, and built the library. OK, great, now I have something called MyLibrary.a.

How and where do I add this into my other Projucer Projects where I want to incorporate it and replace the common code?

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [April 28, 2020, 9:32am UTC](https://forum.juce.com/t/how-to-add-a-juce-built-static-library-into-another-projucer-project/39060/2 "2020-04-28T09:32:41Z")

</div>

I would advise to create a JUCE module instead, if its just for code re-usability.

If you do really need to create a static library:

There are sections in the Projucer Exporters for adding libraries to a project, **External Libraries to Link** and **Library** / **Header Search Paths** :

 ![Screenshot 2020-04-28 at 10.25.19](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/d/d2505b78fc934753e865a581d095b17d026a3a90.png)

 ![Screenshot 2020-04-28 at 10.25.39](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/d/d099bc6db28e6a4b39d5476d5ad54f5434318917.png)

You can also add an Xcode subproject for Mac/iOS projects which is a nice way to work if you do need a separate library for distributing, as you can develop the library alongside the app that uses it.

---

<div class="post-metadata">

**Author:** ![stephenk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stephenk/32/15198_2.png) [@stephenk](https://forum.juce.com/u/stephenk)\
**Post date:** [April 29, 2020, 12:24am UTC](https://forum.juce.com/t/how-to-add-a-juce-built-static-library-into-another-projucer-project/39060/3 "2020-04-29T00:24:18Z")

</div>

Thanks for that info. I’d like to look into the module option, but is there any good reference on how to create a JUCE module? I’m not finding much so far…

---

<div class="post-metadata">

**Author:** ![eyalamir](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyalamir/32/2978_2.png) [@eyalamir](https://forum.juce.com/u/eyalamir)\
**Post date:** [April 29, 2020, 12:51am UTC](https://forum.juce.com/t/how-to-add-a-juce-built-static-library-into-another-projucer-project/39060/4 "2020-04-29T00:51:38Z")

</div>

JUCE modules are really just a big “.h” file including your other header files, and a “.cpp” file including your source files, along with some metadata that helps the projucer parse it for different projects.

Have a look at one of the simpler JUCE provided modules, like juce\_osc to get started - it’s quite simple to copy/paste to a new location, add your own sources/metadata and add to the projucer.

The main thing to note when porting existing code to a JUCE module is that all the code in a module will share the same translation unit, so you probably want to remove all #include statements from them (especially JuceHeader.h), and look out for other things (const variable names, for example) that might cause name conflicts.

---

<div class="post-metadata">

**Author:** ![yfede](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yfede/32/506_2.png) [@yfede](https://forum.juce.com/u/yfede)\
**Post date:** [April 29, 2020, 7:13am UTC](https://forum.juce.com/t/how-to-add-a-juce-built-static-library-into-another-projucer-project/39060/5 "2020-04-29T07:13:51Z")

</div>

> [@stephenk](#):
>
> but is there any good reference on how to create a JUCE module? I’m not finding much so far…

If it can be of any help, in the past I have written some notes to myself on how to structure a JUCE module, based on some guesswork in addition to what’s written in the official `JUCE Module Format.txt` which is found in JUCE codebase:

[https://www.dropbox.com/s/uc115mcuomyl09y/Module%20Guidelines.html?dl=1](https://www.dropbox.com/s/uc115mcuomyl09y/Module%20Guidelines.html?dl=1)

(disclaimer: this was written a few years ago and some details may have changed a little, especially with the introduction of JUCE 6, but the overall description is still valid IMHO)

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [April 29, 2020, 8:06am UTC](https://forum.juce.com/t/how-to-add-a-juce-built-static-library-into-another-projucer-project/39060/6 "2020-04-29T08:06:34Z")

</div>

Also you can check some examples of modules here: [https://github.com/reFX/juce-modules](https://github.com/reFX/juce-modules)
