# Command line application help

I’m trying to use the Audio Device handling classes of Juce in my command line application and at the moment I can’t get it to work.

My question is this, do I need to use the full juceapplication wrapper for my application, or can I just use the Juce classes as is? I read an old post that says that if I don’t want to use Juce’s event handling then I can just use the classes straight off. This isn’t working for me at the moment however, my application breaks in juce_messagelistener.cpp.

any help greatly appreciated.

mark

Which intialise/shutdown methods are you using? I think you have to use initialiseJuce_GUI and shutdownJuce_GUI if you’re using the audio classes, even with a console app. I don’t make console programs myself, but it sounds like something I’ve read around here.

Ah that sounds like it could be the problem, i was using the nonGUI intialising function. Now I’ve changed my project to use initialiseJuce_GUI(), but on running it vc++ claims it’s detected memory leaks, the dump is below. The project is just a vanilla win32 console application with the intialiseJuce_Gui function added to main.

mark

[code]

JUCE v1.45
Detected memory leaks!
Dumping objects ->
Data: < > 00 00 00 00 00 00 00 00 90 06 00 00 1A 04 00 00
Data: < > 00 00 00 00 00 00 00 00 90 06 00 00 FC 03 00 00
Data: <8nq (nq > 38 6E 71 00 28 6E 71 00 00 00 00 00 00 00 00 00
Data: < DD > FF BB BB FF FF 44 44 FF 00 00 00 FF FF BB BB FF
Data: < > 00 01 00 01 01 01 00 01 02 01 00 01 00 0D 00 01
Data: 64 44 71 00 00 68 B3 00 48 00 00 00 08 00 00 00
Data: <,Pq > 2C 50 71 00 CD CD CD CD CD CD CD CD CD CD CD CD
Data: < ( ( e e > A4 28 B3 00 B0 28 B3 00 9C 65 B3 00 9C 65 B3 00
Data: < J u c e > 01 00 00 00 0A 00 00 00 4A 00 75 00 63 00 65 00
Data: < Qq @c $> 80 51 71 00 40 63 B3 00 00 00 00 00 E0 A0 24 00 c:\users\wood\downloads\juce\src\juce_appframework\events\juce_messagemanager.h(191) : {157} normal block at 0x00B32238, 108 bytes long. Data: <$q \$q > A8 24 71 00 98 24 71 00 FA 00 00 00 FA 00 00 00
Object dump complete.[/code]

It’s pretty tough to track down a memory leak just from the listing.

You’re calling shutdownJuce_GUI, right?

Yeah, looks like you’re missing the shutdownJuce_GUI call from that dump. Having said that, I just made a quick app, and I get a leak in juce_message.h, even with a shutdown call.

[code]#include “…/…/…/juce.h”

void func();

int main(int argc, char** argv)
{
initialiseJuce_GUI();
func();
shutdownJuce_GUI();
return 0;
}

void func()
{
ToneGeneratorAudioSource source;
AudioSourcePlayer player;
player.setSource(&source);