Some tips for building libjuce


I’ve found compiling Juce and getting my evironment set up for it to be a bit difficult, especially since I reinstall and change OS’s often. So I thought I’d share how I did it just now on Kubuntu 6.10 (which should apply to most people on various Kubuntu versions, Ubuntu, or Debian).

I found I needed to get the following packages (apt-get or Adept Manager) to compile JUCE:

I am using Eclipse 3.2.x and the CDT (C development toolkit) and found the best way to setup the project is to first make a JUCE workspace with a standard (not managed) makefile C++ project. I imported the JUCE file structure.

In the juce/build/linux/platform_specific_code, I needed to change the path of juce_Config.h in many of the files. And somewhere in the code (I forget where), another include is messed up due to casing (some letter in an include is uppercase instead of lower).

Then I ran premake from the console with the command found in runpremake (this is all in juce/build/linux). Then I selected Project > Clean from the menu in Eclipse to build it.

Next I created my app’s workspace and project (used a standard makefile). I then moved the JUCE workspace into my app workspace. Next I right clicked my project in the tree on the left window, chose Properties > C/C++ Project Paths > Libraries > Add External Library and selected libjuce.a. I then created my premake.lua file like Jule’s Demo app’s premake file, changing the paths to match my system. Finally, I used Jule’s HelloWorld main.cpp file to test everything and changed the include path for juce.h. After running premake and cleaning from within Eclipse, it worked. Woot woot :0


weird… :open_mouth:


Thanks Dan. Apologies for the juce_Config.h includes not having the full path specified - I’ll get that sorted for next time.


Aha! Told you! Just making all include paths relative to the JUCE source directory and pointing it as an additional include folder for a compiler solves the problem. It’s just that simple!


thanks for this post, i’ve been wanting to get Juce coding working in my ubuntu setup but have not been successful at all! this should hopefully be very helpful.

In fact, one thing i was thinking about doing was setting up a virtual computer for coding with juce. It would be super excellent if MS allowed a version of windows XP to be distributed as a virtual PC [in the ‘appliance’ form, where it’s specifically tailored for only one purpose/application], but alas that’s never going to happen. Imagine how ace that would be - one single download that has everything you need to develop apps using juce, all pre-configured and guaranteed to work!

We are, however, allowed to use something like ubuntu for such a task. So, it should be possible to make a virtual PC appliance - consisting of ubuntu, a dev IDE and all required packages, and the juce libs (already compiled) - that would allow people to simply download one [admittedly large] file that would give them a fully working linux juce development environment. They could even run it from within windows, which would be cool - just load the virtual PC, import your project you’ve been developing in visual C++, compile it and bam you have a linux version to share.

I’m going to have a play around with this idea some time in the near future when i’m at a loose end, as even if it’s not popular, it’s something i’m definitely interested in [i really want to set up a virtual PC for myself using a windows install and visual C++ express, so that i can just burn a virtual PC to disc and never have to install all the required SDKs and stuff EVER again… but i have problems installing my copy of XP on a virtual PC thanks to already being registered].


the Ubuntu/Debian packages don’t have premake on any of the servers I search, so I just get it from sourceforge. Also, in regard to your virtual PC idea (which is an area I’m not familiar with), maybe you would have success using the Ubuntu/Kubuntu live CD–which is the installation CD–and download all the libraries and compilers to a hard drive or flash drive. That way you could carry around your dev environment in your pocket … 8) (You might need to carry extra RAM around too though)

I was reading some other posts in this area and see you get a lot of crap about your includes. Granted my environment has no path char limit (who thought of that!), but I like the relative paths, and as long as people don’t mess with the Juce directory structure, it should work great.

I am mostly a Java developer (which is why Juce seems nice to me), and I find C++ to be so annoying. Libs in Java never have problems like C/++… even when I use them from the source and not bytecode.

Also, maybe you’d consider creating a Debian package that has JUCE and links to all its dependencies. Since you also offer it under GPL I think it would work.


No, you’re missing the point - in this case, I just mistyped the paths in a couple of files, and didn’t notice because my machine was set up in such a way that it built anyway.

Haydxn - I do all my linux stuff in a ubuntu VM, so it’ll certainly work! The download’s very big, though.

Dan - yes, it’d be cool to have juce in a package, but I’ve never done that kind of thing so would have to follow a learning curve. Maybe one day when I have a free moment (as if…)


if instead of ubuntu you use gentoo… then you have a ready made overlay that have juce ebuild and a lot of rocking ass audio applications (i’ve moved completely from my M$ studio to a GNU one and i’m very very happy). isn’t updated yet (bit too old version of juce) but i’m working with them to provide the lacking versions of the lib till 1.40.
anyway going to vmware appliances you’ll find a couple of ubuntu vms with preinstalled a lot of development packages (like this, already setup to build with juce, you need to only download a couple of packages as dan suggested
and i’m doing the opposite as jules do: having my windows as VM for coding in it… :wink:


I just downloaded the JUCE 1.4.0 source, and found that it was necessary to change line 36 in the file ‘juce_IIRFilterAudioSource.h’ in order for the library to build.


Change line 36: #include "../../../juce_core/containers/juce_OWnedArray.h"

to #include "../../../juce_core/containers/juce_OwnedArray.h"

The uppercase “W” makes the path invalid since *nix file names are case-sensitive. FYI, I am building under Ubuntu v6.10 (Edgy) using gcc version 4.1.1, and installed the following packages before building:


has anyone managed to get juce built as shared library (.so) ?

i’ve tried doing so, and i’m getting a couple of complaints of gcc:

juce_Atomic.h: In function `int juce::atomicDecrementAndReturn(int&)': juce_Atomic.h:108: error: can't find a register in class `BREG' while reloading `asm'

juce_LowLevelGraphicsSoftwareRenderer.cpp: In function `void juce::blendRectRGB(juce::uint8*, int, int, int, const juce::Colour&)': juce_LowLevelGraphicsSoftwareRenderer.cpp:247: error: PIC register `ebx' clobbered in `asm'

juce_linux_SystemStats.cpp: In function `unsigned int juce::getCPUIDWord(int*, int*)':
juce_linux_SystemStats.cpp:67: error: can't find a register in class `BREG' while reloading `asm'

the first is easy to fix, sharing the same code as atomicDecrement plus returning a copy of the variable on the stack. the other two are quite more obscure (and strange also!).

if anyone can help here is highly appreciated !


to permit a proper fPIC building of the juce lib as a shared library on linux i had to change the following:

juce_Atomic.h (75)

    forcedinline int atomicIncrementAndReturn (int& variable) throw()


        int result;

        __asm__ __volatile__ (

            "lock xaddl %%eax, (%%ecx) \n\

             incl %%eax"

            : "=a" (result)

            : "c" (&variable), "a" (1)

            : "memory");

        return result;



    forcedinline int atomicDecrementAndReturn (int& variable) throw()


        int result;

        __asm__ __volatile__ (

            "lock xaddl %%eax, (%%ecx) \n\

             decl %%eax"

            : "=a" (result)

            : "c" (&variable), "a" (-1)

            : "memory");

        return result;

juce_LowLevelGraphicsSoftwareRenderer.h (246)

                : "cc", "eax", "edx", "memory"    /* Clobber list */
juce_linux_SystemStats.cpp (67)

    __asm__ ("push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx"
    	     : "=a" (family), "=D" (ext), "=c" (dummy), "=d" (cpu)
  		     : "a" (1));

hope to see in the next release !

(p.s. native linux VSTs with juce is a reality!)


I’d like to see a “make install” option for those Linux users who are familiar with the GNU tools for getting their headers and libraries over to /usr/local (or wherever it’s configured on your system).

In the meantime, the following script is working nicely run from the build/linux directory:

#!/bin/bash echo "Copying header files..." cd ../.. mkdir -p /usr/local/include/juce cp -R *.h src /usr/local/include/juce/ cd build/linux echo "Copying libjuce.a..." cp ../../bin/libjuce.a /usr/local/lib


Using Dan’s original post I was able to get JUCE compiled within Eclipse/CDT, and I decided to expand on what Dan describes and make a more detailed noobie guide to using Eclipse (with varous info repeated from above as well). I am using Ubuntu 6.10 Edgy, and I am assuming that g++, Eclipse, and CDT are already installed:

  1. Use Synaptic to install:



  1. Go to and get premake. It is a precompiled binary. Unpack it and copy it to /usr/bin

  2. Unpack the JUCE archive. You will get a folder called “juce”.

  3. Make a folder in your home directory “JUCEWork”

  4. In Eclipse menu File–>Switch Workspace… browse to the new folder JUCEWork and select it. Eclipse restarts. Once past the welcome page, menu Window–>Open Perspective–>Other… select C/C++

  5. In menu File–>New–>Project… select C/C+±->Standard Make C++ Project. Next. Name the project JUCE. Finish (no need to go further with Next)

  6. If you open the JUCE project tree you will see only the default includes folder at this time. Turn off automatic building with menu Project–>Build Automatically, uncheck. Select the Console (at the bottom of the perspective) and you will see an attempt to make all, which fails. Ignore it.

8 ) Select/highlight the (top level) JUCE project and right-click. Select “Import…”. In the wizard select General–>File System. Next. Browse the “From Directory” and pick the “juce” directory from the original JUCE archive unpack. OK. Check the box next to “juce”. Finish. The entire JUCE file tree will be copied into the workspace.

  1. Open the source tree to src–>juce_appframework–>audio–>audio_sources, open juce_IIRFilterAudioSource.h Go to line #37 (to see line numbers: menu Window–>Preferences…–>General–>Editors–>Text Editors, check Show Line Numbers) and change the “W” to a “w”:

#include “…/…/…/juce_core/containers/juce_OWnedArray.h”


#include “…/…/…/juce_core/containers/juce_OwnedArray.h”

  1. Save and Close file juce_IIRFilterAudioSource.h Close the “src” section of the project tree.

  2. Select/highlight the JUCE project. Right-click the project icon and select “Properties” (at bottom). Go to C/C++ Make Project. In Build Location–>Build directory click the Workspace… button and select the JUCE–>build–>linux part of the tree (or just type /JUCE/linux/build into the Build directory text box). Click OK.

  3. You can run the “runpremake” (you need to chmod +x the file) in order to generate the makefile, or we can run it from within Eclipse as follows: Open the JUCE project tree, then the “build” section, and then the linux folder. Make sure the “linux” folder is highlighted, and right-click it. It is important to be at this part of the tree to get the relative path correct for the custom build targets (which in this case really isn’t a make target). Select “Create Make Target…”. In the “Create a new make target” dialog in Target Name type RunPremake. Clear out the Make Target text field. In Build Command uncheck “default”, and instead of “make” type in: bash runpremake In Build Setting uncheck “Run all project builders”. Click the Create button.

  4. Again right-clicking the “JUCE” project select “Build Make Target…” and in the dialog note that the location relative to the folder you right-clicked on (JUCE in this case) shows the “Location” of the RunPremake target is correct relative to the folder we right-clicked, so it should be “build/linux”. Select RunPremake and click the Build button. In the Console window the message “bash runpremake” will appear followed by a long wait for results, but there is a ticker in the lower right corner to indicate work. Then we get the final message “Generating GNU makefiles: …JUCE”.

  5. Select/highlight the JUCE project. In main menu select Project–>Clean… In the Clean dialog select “Clean projects selected below” and make sure the JUCE project is checked. “Start a build immediately” is also checked. OK. In the Console the messages “Cleaning JUCE” and then “Building JUCE” followed by the entire list of source files being compiled. Then the final message “Linking JUCE”. The final result library is in the JUCE/bin directory as libjuce_debug.a

  6. We have, by default, created the “Debug” version of the JUCE library. In order to get a “Release” version, create another Make Target. Open the JUCE project tree, then the “build” section, then the linux folder/section. Make sure the “linux” folder is highlighted, and right-click it. Again it is important to be at this part of the tree to get the relative path correct. Select “Build Make Target…” (we could also use Create but we won’t). In the Build dialog click the Add button (which invokes the Create dialog) and name it ReleaseVersion. Leave the “all” target, and uncheck the “Use default” command and type in a build command of: make CONFIG=Release Leave the “Run all project builders” checked. Click the Create button. Back at the Build dialog we can select ReleaseVersion and click the Build button. This will create the libjuce.a file in the JUCE/bin directory.

  7. Release Version warnings: you may get warnings from files juce_OutputStream.cpp and juce_linux_Windowing.cpp like this: “warning: dereferencing type-punned pointer will break strict-aliasing rules”, and was already noted in the forum here:


I got this to work too:

  1. Demo - Open the tree to demo–>build–>linux. Right click and select Build Make Targets… There should not be any targets listed because we are in a different part of the tree than the library. Click the Add button and name this “RunDemoPremake”. Clear out the Make Target text, uncheck the “Use default” command, and type in bash runpremake, and uncheck the “Run all project builders”. Click Create. Add another target and name it DemoMakeAll. Leave everything else and click Create. Select the RunDemoPremake and click Build. In the Console the message “bash runpremake” followed by “Generating GNU makefles:…JuceDemo” should appear. Then right click the demo/build/linux folder and “Make Build Target…” and select DemoMakeAll. You should see “Building JuceDemo”, the compilation files, and “Linking JuceDemo”. The resulting executable “jucedemo” is in the build directory below this level, i.e. JUCE/demo/build/linux/build.


suffering fuck!

the whole Eclipse “workspace” thing is highly fucked up!!!

why oh why oh why the fuck cant you create a project in a subfolder of the so-called workspace?!?!?!?!?!?

Am I missing something? Jeesus this crap makes Visual Studio look good.


[quote=“Karbon L. Forms”]suffering fuck!

the whole Eclipse “workspace” thing is highly fucked up!!!

why oh why oh why the fuck cant you create a project in a subfolder of the so-called workspace?!?!?!?!?!?

Am I missing something? Jeesus this crap makes Visual Studio look good.[/quote]

Well, try using Code::Blocks IDE instead.


Well, try using Code::Blocks IDE instead.[/quote]

forget, Eclipse obscure the sun and it’s too dark you can’t even see source code.

Code::Rocks !


Vim ftw! 8)
We dont need no stinkin IDE.




reminds me of miserable hours debugging fortan. Ugh.


sacked eclipse. farking shite.

got about 36465783982374 missing dependencies for Code::Blocks so now doing such things as compiling gcc 4.1 so I can compile glibc2.4. yawn…

in the meantime I wrote my first makefile!

fuck vi. using windys editor (editplus for now) with access to linux filesystem. VNCed into linux box otherwise.

don’t you hate bosses and the whims they take?!?!