Start Juce App

After upgrading juce to the latest, my application is no longer launching Juce GUI anymore. The C application was previously calling Juce from a pthread, and it worked. After upgrading, I received a compile error, until I implemented the new member for JUCEApplication::main. But now the GUI doesn’t launch.

Code:

//START_JUCE_APPLICATION (JUCEUCSniffApplication)
void *startUCSniffJUCEGUI(void *){

        startJUCE();
        return NULL;
}
int startJUCE ()
{
        const char *argv[] = {"ucsniff.exe"};
        //return JUCE_NAMESPACE::JUCEApplication::main (1, argv, new JUCEUCSniffApplication());
        return JUCE_NAMESPACE::JUCEApplication::main (1, argv);
}

This line here:

return JUCE_NAMESPACE::JUCEApplication::main (1, argv, new JUCEUCSniffApplication());

Used to successfully launch Juce GUI because it was implemented in juce_amalgamated as:

int JUCEApplication::main (int argc, char* argv[],
                           JUCEApplication* const newApp)
{

The new juce_amalgamated only includes two implementations for main:
1)

int JUCEApplication::main (int argc, const char* argv[])
int JUCEApplication::main (const String& commandLine)

Is there any new implementation member that can still return the JUCEApplication* const newApp, so that a thread can successfully call Juce?

Using “START_JUCE_APPLICATION (JUCEUCSniffApplication)” isn’t an option because the C application already uses main() and there will be duplicate mains.

Have a look at the ScopedJuceInitialiser_GUI class.

Thanks…This is perfect.

I tried to implement initialiseJuce_GUI() as below, but when I launch the main C application, Juce doesn’t launch. Does this look correct below or does something else need to be added?

I was looking at sample implementations in the Forums, and it looks like “initialiseJuce_GUI” is used, but I don’t understand how it knows the name of the JuceApplication object, JUCEUCSniffApplication, in the line:

//START_JUCE_APPLICATION (JUCEUCSniffApplication)
// This macro creates the application's main() function..
//START_JUCE_APPLICATION (JUCEUCSniffApplication)

void *startUCSniffJUCEGUI(void *){

        startJUCE();
        return NULL;
}

int startJUCE ()
{ 
        initialiseJuce_GUI();

        //char *argv[] = {"ucsniff.exe"};
        //return JUCE_NAMESPACE::JUCEApplication::main (1, argv, new JUCEUCSniffApplication());

        //const char *argv[] = {"ucsniff.exe"};
        //return JUCE_NAMESPACE::JUCEApplication::main (1, argv);
}