Author Topic: wxWidgets/Code::Blocks Nightly Build/MinGW  (Read 10778 times)

MVP

  • Guest
wxWidgets/Code::Blocks Nightly Build/MinGW
« on: May 01, 2006, 09:30:27 pm »
Im having trouble compiling a wxWidgets application.

I follow this: Compiling_WxWidgets_With_MSYS-MinGW
I copy the libs it makes into my wxWidgets lib directory. I create a wxWidgets app and tell it my wxWidgets directory.
I link the libraries.

I compile and get:
main.cpp:: undefined reference to `_imp___ZN12wxAppConsole17CheckBuildOptionsEPKcS1_'
main.cpp:: undefined reference to `_imp___Z7wxEntryP11HINSTANCE__S0_Pci'
main.cpp:: undefined reference to `_imp__wxFrameNameStr'
main.cpp:: undefined reference to `_imp__wxDefaultSize' ... etc.

I guess I missed some steps, After creating a wxApplication project I put the minimal wx example into main.cpp.

Thanks, MVP.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: wxWidgets/Code::Blocks Nightly Build/MinGW
« Reply #1 on: May 01, 2006, 09:40:40 pm »
Hello,

I usually build wxWidgets with MinGW by following these instructions:

http://forums.codeblocks.org/index.php?topic=1701.0

Moreover, instead of copying the libraries, you can define and use a global variable.

Best wishes,
Michael

PS.: Do not forget to post which C::B revision are you using, OS and eventually GCC version :).

MVP

  • Guest
Re: wxWidgets/Code::Blocks Nightly Build/MinGW
« Reply #2 on: May 01, 2006, 10:22:00 pm »
Using April 30, 2006 nightly build, wxWidgets 2.6.3, Windows XP, MinGW (current)

Thanks for the reply, I followed the "Compile wxWidgets in Unicode mode" section.

Now I get a lot less errors. :)

Still 3 more though not sure why:
:: warning: ./wx_pch.h.gch/default_wx_pch.h.gch: created by version `3.4.4 (mingw special)', but this is version `3.4.2 (mingw-special)'
main.cpp:: undefined reference to `_imp___ZN8wxString6PrintfEPKcz'
:main.cpp:: undefined reference to `_imp___ZN12wxStringBase8InitWithEPKcjj'
:main.cpp:: undefined reference to `wxApp::Initialize(int&, char**)'

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: wxWidgets/Code::Blocks Nightly Build/MinGW
« Reply #3 on: May 01, 2006, 10:41:59 pm »
:: warning: ./wx_pch.h.gch/default_wx_pch.h.gch: created by version `3.4.4 (mingw special)', but this is version `3.4.2 (mingw-special)'

Which GCC version (not MinGW) are you using? If 3.4.2, you might want to update to GCC 3.4.5 (but before update win32api and binutils files).

Also did you check the include files and libraries are included correctly?

Best wishes,
Michael

MVP

  • Guest
Re: wxWidgets/Code::Blocks Nightly Build/MinGW
« Reply #4 on: May 01, 2006, 11:30:55 pm »
Thanks again, I downloaded the updated core gcc, binutils, and g++, and overwrote them over my mingw installation, im guessing thats bad but the installer wouldnt grab the latest candidate, it was getting 3.4.4 not 3.4.5 and so I improvised.  :shock:

The include directories, etc. I left as default, I only set the base dir of wxWidgets.

Attachment shows the links.

Edit: Updating mingw stuff according to wiki

[attachment deleted by admin]
« Last Edit: May 01, 2006, 11:39:09 pm by MVP »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: wxWidgets/Code::Blocks Nightly Build/MinGW
« Reply #5 on: May 02, 2006, 12:00:11 am »
Thanks again, I downloaded the updated core gcc, binutils, and g++, and overwrote them over my mingw installation, im guessing thats bad but the installer wouldnt grab the latest candidate, it was getting 3.4.4 not 3.4.5 and so I improvised.  :shock:

What I have done was to use the installer MinGW 5.0.2 (selected candidate), to update win32api and binutils files and then to download and install GCC 3.4.5. The installer just install 3.4.4 as candidate and IIRC 3.4.2 as stable. Na ja, to be honest, I have also copied and pasted my MinGW directory and installed GCC 4.1.0 from Ceniza. This means that I have 2 MinGW installations under C:

C:\MinGW
C:\MinGW_345

In case of need I can just switch to the other, but just renaming it to MinGW :).

Best wishes,
Michael

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: wxWidgets/Code::Blocks Nightly Build/MinGW
« Reply #6 on: May 02, 2006, 12:14:36 am »
Concerning the libraries and include files, this is what I have in an application I was developing:

I have under compiler-->#defines:

Quote
__WX__
WINVER=0x0400
__GNUWIN32__
HAVE_W32API_H
__WXMSW__
WXUSINGDLL
wxUSE_UNICODE

Under other compiler-->Other options:

Quote
-pipe
-mthreads
-fexceptions
-Winvalid-pch

Under Linker-->Link libraries:

Quote
wxmsw26$(WX_SUFFIX)

Under Directories-->Compiler:

Quote
$(#WX.lib)\gcc_dll\msw$(WX_SUFFIX)
$(#WX.lib)\gcc_dll$(WX_CFG)\msw$(WX_SUFFIX)
$(#WX)\contrib\include
$(#WX.include)

Under Directories-->Linker:

Quote
$(#WX.lib)\gcc_dll
$(#WX.lib)\gcc_dll$(WX_CFG)

The wxWidgets library I use (unicode dll) is the same as the one I use to build C::B (as same are some of the settings :)).

Best wihses,
Michael

MVP

  • Guest
Re: wxWidgets/Code::Blocks Nightly Build/MinGW
« Reply #7 on: May 02, 2006, 12:27:22 am »
Hey thanks a lot, it seemed to work, It compiles now but when I go to run it it terminates right away with an error:
AppName: wxwidgets.exe    AppVer: 0.0.0.0    ModName: wxmsw26u_gcc_custom.dll
ModVer: 2.6.3.0    Offset: 00061f17

Here is the code im compiling, its from the wxwidgets sample directory
Code
/////////////////////////////////////////////////////////////////////////////
// Name:        minimal.cpp
// Purpose:     Minimal wxWidgets sample
// Author:      Julian Smart
// Modified by:
// Created:     04/01/98
// RCS-ID:      $Id: minimal.cpp,v 1.67 2005/02/20 16:14:03 JS Exp $
// Copyright:   (c) Julian Smart
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

// ============================================================================
// declarations
// ============================================================================

// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------

// the application icon (under Windows and OS/2 it is in resources and even
// though we could still include the XPM here it would be unused)
#if !defined(__WXMSW__) && !defined(__WXPM__)
    #include "../sample.xpm"
#endif

// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------

// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
public:
    // override base class virtuals
    // ----------------------------

    // this one is called on application startup and is a good place for the app
    // initialization (doing it here and not in the ctor allows to have an error
    // return: if OnInit() returns false, the application terminates)
    virtual bool OnInit();
};

// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public:
    // ctor(s)
    MyFrame(const wxString& title);

    // event handlers (these functions should _not_ be virtual)
    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);

private:
    // any class wishing to process wxWidgets events must use this macro
    DECLARE_EVENT_TABLE()
};

// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------

// IDs for the controls and the menu commands
enum
{
    // menu items
    Minimal_Quit = wxID_EXIT,

    // it is important for the id corresponding to the "About" command to have
    // this standard value as otherwise it won't be handled properly under Mac
    // (where it is special and put into the "Apple" menu)
    Minimal_About = wxID_ABOUT
};

// ----------------------------------------------------------------------------
// event tables and other macros for wxWidgets
// ----------------------------------------------------------------------------

// the event tables connect the wxWidgets events with the functions (event
// handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(Minimal_Quit,  MyFrame::OnQuit)
    EVT_MENU(Minimal_About, MyFrame::OnAbout)
END_EVENT_TABLE()

// Create a new application object: this macro will allow wxWidgets to create
// the application object during program execution (it's better than using a
// static object for many reasons) and also implements the accessor function
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
// not wxApp)
IMPLEMENT_APP(MyApp)

// ============================================================================
// implementation
// ============================================================================

// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------

// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
    // create the main application window
    MyFrame *frame = new MyFrame(_T("Minimal wxWidgets App"));

    // and show it (the frames, unlike simple controls, are not shown when
    // created initially)
    frame->Show(true);

    // success: wxApp::OnRun() will be called which will enter the main message
    // loop and the application will run. If we returned false here, the
    // application would exit immediately.
    return true;
}

// ----------------------------------------------------------------------------
// main frame
// ----------------------------------------------------------------------------

// frame constructor
MyFrame::MyFrame(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title)
{
    // set the frame icon
    SetIcon(wxICON(sample));

#if wxUSE_MENUS
    // create a menu bar
    wxMenu *fileMenu = new wxMenu;

    // the "About" item should be in the help menu
    wxMenu *helpMenu = new wxMenu;
    helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Show about dialog"));

    fileMenu->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));

    // now append the freshly created menu to the menu bar...
    wxMenuBar *menuBar = new wxMenuBar();
    menuBar->Append(fileMenu, _T("&File"));
    menuBar->Append(helpMenu, _T("&Help"));

    // ... and attach this menu bar to the frame
    SetMenuBar(menuBar);
#endif // wxUSE_MENUS

#if wxUSE_STATUSBAR
    // create a status bar just for fun (by default with 1 pane only)
    CreateStatusBar(2);
    SetStatusText(_T("Welcome to wxWidgets!"));
#endif // wxUSE_STATUSBAR
}


// event handlers

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    // true is to force the frame to close
    Close(true);
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxString msg;
    msg.Printf( _T("This is the About dialog of the minimal sample.\n")
                _T("Welcome to %s"), wxVERSION_STRING);

    wxMessageBox(msg, _T("About Minimal"), wxOK | wxICON_INFORMATION, this);
}

EDIT: Awesome, thanks dude, I just had to copy the setup.h into the includes folder and it works.  :D
« Last Edit: May 02, 2006, 12:39:54 am by MVP »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: wxWidgets/Code::Blocks Nightly Build/MinGW
« Reply #8 on: May 02, 2006, 12:57:41 am »
EDIT: Awesome, thanks dude, I just had to copy the setup.h into the includes folder and it works.  :D

Glad that it works :).

Anyway, be careful when you copy setup.h. Look at here (more info are available in the forum):

http://forums.codeblocks.org/index.php?topic=2857.msg22824#msg22824

Best wishes,
Michael