Netbeans and wxWidgets

Setup Netbeans for wxWidgets

This guide is made for systems with Windows, TCD-GDM Compiler (MinGW GCC), wxWidgets 3.1 (SHARED=0), wxConfig and MSYS. But the procedure should be similar if not identical on other setups. MSYS is required by Netbeans.

Setup the compiler/tools collection

  1. Go to Tools -> Options -> C/C++ -> Build Tools -> Add...
  2. Then choose the bin folder under your compiler install-location.
  3. For make we use MSYS' make located in msys bin folder.

You can also input your qmake and cmake if you want, but not neccesary for now.

Example configuration:

Make a new wxWidgets project

Go to File -> New Project -> C/C++ -> C/C++ Application.

Now right-click your project -> Properties -> Build. Make sure the Tool Collection is set to whatever you configured in the previus step. Also note at the top what Configuration you are configuring (Debug or Release).

  1. Go to C++ Compiler
  2. Under Include Directories add your include directory located in your wxWidgets instalation.
  3. Under Additional Options, add:
    `wx-config --cxxflags --wxcfg=gcc_lib/mswu`

    where mswu is release and mswud is debug. These represent folders inside wxWidgets lib folder respectively.

Example configuration:

Go to Linker, under Additional Options, add:

`wx-config --libs --wxcfg=gcc_lib/mswu` -lshlwapi -lversion

Since wxWidgets 3.1 you have to add -lshlwapi -lversion or the link may fail.

Example configuration:

Paste the code bellow into your main.cpp file and compile! It should work :)

#include "wx/wxprec.h"

#ifndef WX_PRECOMP
#   include "wx/wx.h"
#endif

class HelloWorldApp : public wxApp
{
public:
    virtual bool OnInit();
};

DECLARE_APP(HelloWorldApp)

IMPLEMENT_APP(HelloWorldApp)

bool HelloWorldApp::OnInit()
{
    wxFrame *frame = new wxFrame((wxFrame*) NULL, -1, _T("Hello wxWidgets World"));
    frame->CreateStatusBar();
    frame->SetStatusText(_T("Hello World"));
    frame->Show(true);
    SetTopWindow(frame);
    return true;
}

This is what the program looks like when compiled and running under Windows 7: