[newbie] Using JUCE with existing code


#1

Newbie question, I know this is likely obvious… I want to use JUCE in my present application to use its audio functions. It says on the intro:

So I downloaded JUCE, and now I have a folder called “juce”. I put the juce folder’s path in my projects XCode Header Search paths. I took one of my header files and wrote #include <juce.h>. Then, in that headers accompanying .cpp file, I put a function called TestJUCE(), also declared it in the .h file, and wrote this:

void TestJUCE()
{
OggVorbisAudioFormat* ogg = new OggVorbisAudioFormat();
bool rtBool = ogg->canDoStereo();
}

Upon compiling and linking, I get a link error, Symbol not found.

I’ve kept this real simple because I just was following the above intro instruction. What am I doing incorrectly?


#2

Sorry, that text is way out of date and I must update it… (Although to be fair you’ve mis-read it anyway: when it says “add a single CPP file”, it doesn’t mean your cpp file, it means the one with all the juce code in it, hence your link error)

But ignore all that anyway: instead if you’re a noob, it’s best to just download the introjucer, and use its wizard to create yourself a starter project.


#3

Thanks for your quick reply.

Actually I was going to ask (just forgot) about “what is that single cpp file you are referring to?” - and I’d still like to know which one it is. The only candidate I would think is “juce_amalgamated.cpp”.

Plus I’m further confused - I’m trying to use JUCE with a project that already exists, so checking out the introjucer seems like the long way around. I did open the IntroJucer and tried to figure it out, but it really seems more concerned about laying the basis for a JUCE app from scratch. I’m not trying to do that, I’m trying to use JUCE’s audio library functions with a project that already exists.


#4

Add juce_core.cpp, juce_audio_basics.cpp, juce_audio_devices.cpp to your existing project. If you need more add the appropriate module .cpp files (like juce_audio_formats.cpp for example).


#5

You can also still use the juce_amalgamated.h/juce_amalgamated.cpp files too, which just pulls in all the module code.


#6

But also, if you use IntroJucer to make a project, you’ll have a nice example to copy from. That’s the way I’ve worked with every single framework I’ve used - get a sample or donor project going to copy from. The exercise of building up the right settings from scratch always seemed disproportionately frustrating. Why not take a shortcut and get to the fun stuff?

Bruce


#7

I tried using Introjucer as an app, I still get the symbol not found stuff.


#8

Thanks, I did already update that stuff on the website. And the introjucer is an app, you can download the binary from sourceforge. Maybe that wasn’t clear…


#9

Thanks everyone, I’m still short of the goal…

TheVinn: I shouldn’t have to include cpp files to my project, should I? I’m used to just coding .h files in, and it’s their responsibility to “go get” the cpp files. It declutters the project area in XCode tremendously, since I"m never going to edit those cpp files anyway.

Please see what I’m doing - I’m simply try to call some incidental function in AudioDataFormat and if my project links, I know I’ve "connected’ with JUCE. I’ve done this:

#include “juce_core/juce_core.h”
#include “juce_audio_formats/juce_audio_formats.h”

I looked and the OggVorbisAudioFormat objet I’m trying to access is definitely in juce_audio_formats.h. Yet I still get the symbol not found error. I inserted

#define JUCE_USE_OGGVORBIS 1

And that didn’t help either.


#10

You need to add those .cpp or else you won’t be able to link.


#11

[quote=“chickeneps”]TheVinn: I shouldn’t have to include cpp files to my project, should I? I’m used to just coding .h files in, and it’s their responsibility to “go get” the cpp files. It declutters the project area in XCode tremendously, since I"m never going to edit those cpp files anyway.

Please see what I’m doing - I’m simply try to call some incidental function in AudioDataFormat and if my project links, I know I’ve "connected’ with JUCE[/quote]

You probably need to revisit what’s going on in a C/C++ compiler. The .h files generally only have a definition of what functions are available to you. Then your app also needs to ‘link’ to those actual functions. Some you will get semi-automatically from the OS. Some will be linked in libraries, either statically or dynamically, and some will be defined in your code, generally in .cpp files.

.h files don’t go and do any linking for you, generally. There are some systems like .hpp files, which is basically a .h and .cpp file wrapped into one.

Like I say, download IntroJucer (binary) and get a smaple app compiling on your machine and IDE chain. Then copy the pieces you need to your other app.
Bruce


#12

OK, thank you, I understand I have to include the cpp files. I have been used to using .h files to link up with .lib/.a files of late and got confused. Thank you Bruce for your advice as well. (Boy, do I feel nooby)

OK, so I started up the IntroJucer. Remember, I already have a dylib project I want to use JUCE with. Is the task for me to make some type of faux pas IntroJucer project that has OggVorbisAudioFormat in it, get it to run, the copy-paste that code to my existing project?

What I didn’t understand about IntroJucer is that the Open In XCode buttons are grayed out, so I’m not really sure what to do with this. Also, the Tools things - I’m not sure what they completely have to do with IntroJucer. I already have Juce 2.0 in a folder on my computer.

I really thank you for your help.


#13

Ah, so you have a library you want to use?

Well, yes, anyway. Make a new IntroJucer project. It should have a few ‘export targets’, including Xcode. Make sure you set your local Juce folder, if it’s not the default.

I suggest you start with something super dumb - just a blank window.

Then generate a project, try to compile, link and run it.

Then start adding your custom stuff, ending with adding in your specific libraries.

Bruce


#14

How do you create an “export target” in the Introjucer? I don’t see any place where that’s an option. All I see is the ability to add .cpp’s and .h to the tree, 6 fields for Project Settings, and a Modules area that I’m not sure what relevance it has. The Open in XCode buttons and menus are always grayed out.

I looked around for Introjucer documentation (I really am trying) and I got this:

http://www.rawmaterialsoftware.com/wiki/index.php/Features#The_Jucer

it says 'A set of wizards make it easy to create application or plugin projects." Where are they? I really don’t have any idea. I’m sorry for sounding so elementary, but I’m really trying…


#15

Ah, so you have a library you want to use?
I suggest you start with something super dumb - just a blank window.[/quote]

No, actually I have a fairly large dylib. It’s not something I can reconstruct easily. I was just after being able to access JUCE FROM the project, not the other way around. And it does not have an interface, I’m just interested in the audio function code.

I did what TheVinn suggested and put in the select .cpp files and .h files, but I got a lot of compile errors when those .cpp files were compiling. I guess I have some work to do on that, nothing I can’t handle.

I was sort of faked out by the outdated “INTEGRATING JUCE INTO A PROJECT” thing that was in the Overview, saying all that was needed was to include juce.h and another .cpp file (didn’t say what it was). I still don’t think it’s accurate to say this is simple. Dealing with link errors isn’t child’s play sometimes. Static libraries and cpp’s that are walking into an app always are going to have this problem, only .dylibs/dll’s with .h files can avoid those type of errors.

Thanks for your help, I’ll post back with good news shortly, hopefully.


#16

Is your copy of AppConfig.h visible from your project’s include paths?

Which .cpp did you add to your project? juce_core.cpp?


#17

OK, so - I didn’t suggest that you rebuild your library project, just that you use baby steps, AKA basic troubleshooting.

And yes, link errors can be a bear. Especially if you don’t have a good grasp of what’s going on. You should probably steer clear of explaining to everyone else what will and won’t always be problems until you have a bit more understanding.

Right click on the orange slice icon that represents your project file in the IntroJucer. Not sure why it didn’t make targets for you. Did you do ‘New…’ to make a new project?

Bruce


#18

The Introjucer is obviously undergoing pretty rapid development at the moment and small things are being fixed all the time. Therefore I always recommend building the Introjucer from the sources yourself, just open the project under juce/extras/Introjucer/Builds/… for your platform, it only takes a second. There was a day or two where it didn’t automatically create an export target for you and if this happens to be the pre-built one currently uploaded you will see this problem.

Also if you’re not up to date with the latest its difficult for us to point you in the right direction as I think most people here are pretty close to the bleeding edge tip due to all the great stuff that comes with it.