Problem compiling a WXwidgets application Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
AcmeMan
In need of some credit
In need of some credit
Posts: 3
Joined: Thu Oct 19, 2006 2:20 pm

Problem compiling a WXwidgets application

Post by AcmeMan »

Hello
Everytime that i've tried to run the following program i got a run-time
error:

#include <wx\wx.h>

int main(int argc, char **argv)
{

wxMessageBox("Hello!");

return 0;
}

No Error during compiling and linking time, but i've a crash every time
that i try to rum the application. I've used dev-cpp and mingw developer
studio but the result is the same.
What's the problem?
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte »

I am not sure such a source code would work.

You should look at the samples delivered with wxWidgets ("samples" directory), especially the "minimal" one.

Now, regarding wether you wish to test a GUI or command line app, the code will be different... (precompiler directives, macro to instanciate the app, ...).

You should not need to write a "main (argc, argv)" function, unless you really have specific requirements with your app.
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag »

this works,

Code: Select all

//headers & declarations
#include <wx/wx.h>
#include <stdio.h>

//"console" like main
int xxmain(int argc, char** argv)
{
    printf(" %3d : %s \n", argc, argv[0]);
    wxMessageBox(argv[0]);
    return argc+20;
}

//wxapp
class MyApp: public wxApp
{
    virtual int OnRun();
};
IMPLEMENT_APP(MyApp)
int MyApp::OnRun()
{
    return xxmain(argc, argv);
}
build it as console application with macro

Code: Select all

wxUSE_GUI=1
defined

brgds
-tiwag
AcmeMan
In need of some credit
In need of some credit
Posts: 3
Joined: Thu Oct 19, 2006 2:20 pm

Post by AcmeMan »

thx
Post Reply