mardi 4 août 2015

How to create a console application in Code::Blocks?

I need to create a console application in Code::Blocks using some of wxWidgets classes (such as wxThread, wxHTTP, ...).

There are no "wxWidgets console application" wizard in Code::Blocks, so I choose just a "Console application", getting main.cpp created with the following code:

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

It compiles and runs Ok. When I replace it with a contents of examples/samples/console/console.cpp from wxWidgets's examples (skipped some text to be shorter):

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif
#include <wx/app.h>
#include <wx/cmdline.h>

// implementation
static const wxCmdLineEntryDesc cmdLineDesc[] =
{
    ...
};

int main(int argc, char **argv)
{
    wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
    //!: **ERROR HERE:^**

    wxInitializer initializer;
    if ( !initializer )
    {
        fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
        return -1;
    }
    ...
    // do something useful here
    return 0;
}

I got "undefined reference to wxAppConsoleBase::CheckBuildOptions(char const*, char const*)" error (gcc) at specified line.

What am I doing wrong?

How to fix this?

I can compile my GUI projects with wxWidgets (version 3.0) with no problem, so it looks like I need to specify some defines, includes or any other magic to make it work. I tried to understand example's makefile, but with no luck.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire