[newbie] Using JUCE with existing code

18 posts / 0 new
Last post
chickeneps
Offline
Last seen: 1 year 5 months ago
Joined: 6 Aug 2012 - 15:07
[newbie] Using JUCE with existing code

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:

Quote:
Adding JUCE to your app is very simple - the easiest way involves simply including juce.h in your files and adding a single cpp file to your project. No need to compile any libraries or worry about dependencies.

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 . 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?

jules
Online
Last seen: 8 min 24 sec ago
Joined: 29 Apr 2013 - 18:37
Re: [newbie] Using JUCE with existing code

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.

chickeneps
Offline
Last seen: 1 year 5 months ago
Joined: 6 Aug 2012 - 15:07
Re: [newbie] Using JUCE with existing code

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.

TheVinn
Offline
Last seen: 1 day 1 hour ago
Joined: 29 Aug 2009 - 11:31
Re: [newbie] Using JUCE with existing code

chickeneps wrote:
I'm trying to use JUCE's audio library functions with a project that already exists.

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).

jules
Online
Last seen: 8 min 24 sec ago
Joined: 29 Apr 2013 - 18:37
Re: [newbie] Using JUCE with existing code

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

Bruce Wheaton
Offline
Last seen: 1 hour 55 min ago
Joined: 17 Aug 2006 - 01:43
Re: [newbie] Using JUCE with existing code

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

chickeneps
Offline
Last seen: 1 year 5 months ago
Joined: 6 Aug 2012 - 15:07
Re: [newbie] Using JUCE with existing code

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

jules
Online
Last seen: 8 min 24 sec ago
Joined: 29 Apr 2013 - 18:37
Re: [newbie] Using JUCE with existing code

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..

chickeneps
Offline
Last seen: 1 year 5 months ago
Joined: 6 Aug 2012 - 15:07
Re: [newbie] Using JUCE with existing code

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.

TheVinn
Offline
Last seen: 1 day 1 hour ago
Joined: 29 Aug 2009 - 11:31
Re: [newbie] Using JUCE with existing code

chickeneps wrote:
TheVinn: I shouldn't have to include cpp files to my project, should I?

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

Bruce Wheaton
Offline
Last seen: 1 hour 55 min ago
Joined: 17 Aug 2006 - 01:43
Re: [newbie] Using JUCE with existing code

chickeneps wrote:
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

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

Pages