Page 1 of 2

wxAUI and Linux

Posted: Sun Oct 29, 2006 7:31 pm
by archivator
I'm having trouble using AUI in my application. The preprocessor finds the headers, yet the compiler complains about wxFrameManager not being a real class. This is the header file that causes me trouble:

Code: Select all

#ifndef MAINFRAME_H_INCLUDED
#define MAINFRAME_H_INCLUDED

#include <wx/wxprec.h>

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

#include "global.h" // defines APP_NAME

class myMainFrame: public wxFrame{
    public:
        static myMainFrame * Get(){
            if(pInstance == 0){
                pInstance = new myMainFrame();
            }
            return pInstance;
        }
    protected:
        myMainFrame(wxWindow* parent = NULL, long id = wxID_ANY, wxString title = APP_NAME);

        wxBoxSizer * m_main_sizer;

        wxPanel * m_center_panel;

        wxFrameManager * m_frame_manager;

        static myMainFrame * pInstance;
        DECLARE_EVENT_TABLE()
};

#endif // MAINFRAME_H_INCLUDED
and these are the errors I get: [quote]mainframe.h:36: error: ISO C++ forbids declaration of

Posted: Sun Oct 29, 2006 7:49 pm
by benedicte
You forgot to add the include to the wxAUI header.

Code: Select all

#include "wx/aui.h"

Posted: Sun Oct 29, 2006 8:26 pm
by archivator
Actually, I do include <wx/aui/aui.h> in global,h. Forgot to mention it, sorry.

Posted: Sun Oct 29, 2006 9:55 pm
by benedicte
Do you get the same error when building the "aui" sample (in the "samples" directory)?

Posted: Mon Oct 30, 2006 6:17 am
by archivator
Surprisingly, no.
I'm using Code::Blocks and its wxWidgets template though I don't think that's the problem as it just uses `wx-config --cflags` and `wx-config --libs` :rolleyes:

Here is the output of `wx-config --cflags` and `wx-config --libs` :

Code: Select all

archiv[email protected]:~$ wx-config --cflags
-I/usr/local/lib/wx/include/gtk2-unicode-debug-2.7 -I/usr/local/include/wx-2.7 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXDEBUG__ -D__WXGTK__ 

[email protected]:~$ wx-config --libs
-L/usr/local/lib -pthread   -lwx_gtk2ud_aui-2.7 -lwx_gtk2ud_xrc-2.7 -lwx_gtk2ud_qa-2.7 -lwx_gtk2ud_html-2.7 -lwx_gtk2ud_adv-2.7 -lwx_gtk2ud_core-2.7 -lwx_baseud_xml-2.7 -lwx_baseud_net-2.7 -lwx_baseud-2.7 

Posted: Mon Oct 30, 2006 9:17 am
by tiwag
the compiler error means clearly, that wxFrameManager isn't defined,
so try to include the aui.h file and look if it compiles then.

maybe you have another "global.h" in your compilers include directories which is found and don't include the "aui.h"

Posted: Mon Oct 30, 2006 9:25 am
by benedicte
You may also try to generate the preprocessed file (usually .i extension). Then, you should see what's wrong in the file the compiler gets as input.

Posted: Mon Oct 30, 2006 11:23 am
by eranif
On g++ compiler use the -E switch to get the path from the compiler extracts its input from, some thing like this;

Code: Select all

g++ -c file.cpp -E > myoutput
myoutpu will contain the same source file as file.cpp, but all paths / driectives are resolved, for exmple:

if in file.cpp you had:

Code: Select all

#include <stdio.h>
myoutput will contain (for exmaple):

Code: Select all

#include "/usr/include/stdio.h"
Apply this to your code, and you will be able to tell from where it locates your AUI header files.

- Eran

Posted: Mon Oct 30, 2006 2:14 pm
by archivator
This whole thing is starting to get on my nerves.

I examined the preprocessed file (thanks for the tip, eranif) and as I suspected, the wx/aui/aui.h header is successfully included :

Code: Select all

# 1 "/usr/local/include/wx-2.7/wx/aui/aui.h" 1
# 15 "/usr/local/include/wx-2.7/wx/aui/aui.h"
# 1 "/usr/local/include/wx-2.7/wx/aui/framemanager.h" 1
# 19 "/usr/local/include/wx-2.7/wx/aui/framemanager.h"
# 1 "/usr/local/include/wx-2.7/wx/defs.h" 1
# 20 "/usr/local/include/wx-2.7/wx/aui/framemanager.h" 2

// snipped most of the AUI classes


class wxFrameManager : public wxEvtHandler
{
friend class wxFloatingPane;

public:

    wxFrameManager(wxWindow* managed_wnd = __null,
                   unsigned int flags = wxAUI_MGR_DEFAULT);
    virtual ~wxFrameManager();
    void UnInit();
// snipped some 90 lines

protected:

    wxWindow* m_frame;
    wxDockArt* m_art;
    unsigned int m_flags;

    wxPaneInfoArray m_panes;
    wxDockInfoArray m_docks;
    wxDockUIPartArray m_uiparts;

    int m_action;
    wxPoint m_action_start;
    wxPoint m_action_offset;
    wxDockUIPart* m_action_part;
    wxWindow* m_action_window;
    wxRect m_action_hintrect;
    bool m_skipping;
    wxRect m_last_rect;
    wxDockUIPart* m_hover_button;
    wxRect m_last_hint;
    wxPoint m_last_mouse_move;

    wxFrame* m_hint_wnd;
    wxTimer m_hint_fadetimer;
    wxByte m_hint_fadeamt;
    wxByte m_hint_fademax;


    private: static const wxEventTableEntry sm_eventTableEntries[]; protected: static const wxEventTable sm_eventTable; virtual const wxEventTable* GetEventTable() const; static wxEventHashTable sm_eventHashTable; virtual wxEventHashTable& GetEventHashTable() const;

};

// fast forward to my code

# 20 "/usr/local/include/wx-2.7/wx/aui/aui.h" 2
# 6 "mainframe.h" 2

class myMainFrame: public wxFrame{
    public:

        static myMainFrame * Get(){
            if(pInstance == 0){
                pInstance = new myMainFrame();
            }
            return pInstance;
        }
    protected:

        myMainFrame(wxWindow* parent = __null, long id = wxID_ANY, wxString title = L"myApp ");


        wxBoxSizer * m_main_sizer;


        wxPanel * m_center_panel;


        wxFrameManager * m_frame_manager;

        static myMainFrame * pInstance;
        private: static const wxEventTableEntry sm_eventTableEntries[]; protected: static const wxEventTable sm_eventTable; virtual const wxEventTable* GetEventTable() const; static wxEventHashTable sm_eventHashTable; virtual wxEventHashTable& GetEventHashTable() const;
};
The command I executed is

Code: Select all

g++ `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DUSE_PCH -Wall -g -W  -I/usr/include -I/usr/local/include/wx-2.7  -c app.cpp -o Debug/obj/app.o -E > mainframe.prep
Any ideas?

Posted: Mon Oct 30, 2006 2:40 pm
by Jorg
I would advice you to remove all compiler flags that have relations with PCH files. Simply let it figure out the hreaders itself instead of using PCH's which might very well be the source of your problems.

- Jorgen

Posted: Mon Oct 30, 2006 3:54 pm
by archivator
Removing the precompiled headers option did no good. I still get the same error. The frustration is getting to me as I've tried everything I can think of; I even checked the wxFrameManager line character by character to see if there's something unusual that confuses the compiler. Nothing!

Of course, the program compiles just fine with the Microsoft C++ compiler (cl.exe).

The only funny thing about this whole thing is that the IDE is smarter than the compiler: C::B's autocomplete function sees the wxFrameManager class and the compiler doesn't (I'm not sure how C::B's autocomplete system works but I don't think it shows all classes from all headers :) ).

I just tried the older g++ v3.3 and all it gives is

Code: Select all

mainframe.h:28: error: syntax error before `*' token
:: === Build finished: 1 errors, 0 warnings ===
I guess it finds the same (invisible) error; the newer one just explains it better.

Posted: Mon Oct 30, 2006 4:09 pm
by benedicte
Did you try Eran's tip on the AUI sample to see the difference?

Is there any difference in the build options/flags between the sample and your app?

Posted: Mon Oct 30, 2006 4:32 pm
by tiwag
check, if you have in every included file a newline at the end of file

Posted: Mon Oct 30, 2006 4:56 pm
by eranif
Can you post the content of "global.h"?
I suspect there is a circular inclusion here.

try this:

declare wxFrameManager as forward declaration;'

Code: Select all

class wxFrameManager
in the cpp file, do the actual include to "global.h"

-Eran

Posted: Mon Oct 30, 2006 5:18 pm
by tierra
You should make sure you have wxUSE_AUI defined and that's it's not set to 0 in any of your setup.h files. A quick grep will find everywhere you need to look (and this is why I like working off a built copy of wxWidgets in it's own folder not installed on the system).