When I use initialiseJuce_GUI(), the Juce GUI is not launching. My apologies in advance for the cross-post, folks, but I really need some help - I’m not sure where to put initialiseJuce_GUI(), or how it needs to be used. This is for an open source security tool that is freely available. The current version is working, but doesn’t compile on Fedora with a juce compile error. When I upgraded juce_amalgamated to the latest, I have some compile errors and found out from Jules that I need to use initialiseJuce_GUI. It compiles on fedora now, but the GUI doesn’t launch. Helping me with this will make Juce even more popular, being used in an open source security tool.
This is the function within a cpp file that is calling initialiseJuce_GUI(). The entire cpp file is below. What am I missing?:
void *startUCSniffJUCEGUI(void *){
int retval = 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);
}
How does the call to initialiseJuce_GUI() know the name of the JUCEApplication, because the call to main used to work before, and it returned the JUCEApplication class name??
This is the relevant C program code and main within that code that is calling the function in the Juce CPP via a thread:
int rc = pthread_create(&threads[0],NULL,startUCSniffJUCEGUI,NULL);
if(rc){
printf("Error Creating thread for JUCE GUI : %d\n",rc);
exit(1);
}
cpp code for JuceUCSniff.cpp:
#include "includes_juce.h"
#include "MainComponent.h"
extern int guiShutdown;
extern "C" {
void *startUCSniffJUCEGUI(void *);
};
extern "C" {
int startJUCE();
}
class UCSniffWindow : public DocumentWindow
{
public:
UCSniffWindow()
: DocumentWindow (T("UCSniff GUI"),
//Colours::lightgrey,
Colours::white,
DocumentWindow::allButtons,
true)
{
MainComponent* const contentComponent = new MainComponent();
setContentComponent (contentComponent, true, true);
centreWithSize (getWidth(), getHeight());
setVisible (true);
}
~UCSniffWindow()
{
}
void closeButtonPressed()
{
// When the user presses the close button, we'll tell the app to quit. This
// window will be deleted by our UCSniffApplication::shutdown() method
//
JUCEApplication::quit();
}
};
//==============================================================================
/** This is the application object that is started up when Juce starts. It handles
the initialisation and shutdown of the whole application.
*/
class JUCEUCSniffApplication : public JUCEApplication
{
/* Important! NEVER embed objects directly inside your JUCEApplication class! Use
ONLY pointers to objects, which you should create during the initialise() method
(NOT in the constructor!) and delete in the shutdown() method (NOT in the
destructor!)
This is because the application object gets created before Juce has been properly
initialised, so any embedded objects would also get constructed too soon.
*/
UCSniffWindow* ucsniffWindow;
public:
//==============================================================================
JUCEUCSniffApplication()
: ucsniffWindow (0)
{
// NEVER do anything in here that could involve any Juce function being called
// - leave all your startup tasks until the initialise() method.
}
~JUCEUCSniffApplication()
{
// Your shutdown() method should already have done all the things necessary to
// clean up this app object, so you should never need to put anything in
// the destructor.
// Making any Juce calls in here could be very dangerous...
}
//==============================================================================
void initialise (const String& commandLine)
{
// just create the main window...
ucsniffWindow = new UCSniffWindow();
/* ..and now return, which will fall into to the main event
dispatch loop, and this will run until something calls
JUCEAppliction::quit().
In this case, JUCEAppliction::quit() will be called by the
hello world window being clicked.
*/
}
void shutdown()
{
// clear up..
if (ucsniffWindow != 0){
delete ucsniffWindow;
guiShutdown = 1;
}
}
//==============================================================================
const String getApplicationName()
{
return T("VIPER Lab UCSniff");
}
const String getApplicationVersion()
{
return T("1.0");
}
bool moreThanOneInstanceAllowed()
{
return true;
}
void anotherInstanceStarted (const String& commandLine)
{
}
};
//==============================================================================
// This macro creates the application's main() function..
//START_JUCE_APPLICATION (JUCEUCSniffApplication)
void *startUCSniffJUCEGUI(void *){
int retval = 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);
}