wxAUI and Linux

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
archivator
Earned a small fee
Earned a small fee
Posts: 14
Joined: Fri Jul 14, 2006 8:56 am

wxAUI and Linux

Post 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
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte »

You forgot to add the include to the wxAUI header.

Code: Select all

#include "wx/aui.h"
archivator
Earned a small fee
Earned a small fee
Posts: 14
Joined: Fri Jul 14, 2006 8:56 am

Post by archivator »

Actually, I do include <wx/aui/aui.h> in global,h. Forgot to mention it, sorry.
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte »

Do you get the same error when building the "aui" sample (in the "samples" directory)?
archivator
Earned a small fee
Earned a small fee
Posts: 14
Joined: Fri Jul 14, 2006 8:56 am

Post 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

archivator@Infinity:~$ 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__ 

archivator@Infinity:~$ 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 
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post 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"
-tiwag
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post 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.
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post 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
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
archivator
Earned a small fee
Earned a small fee
Posts: 14
Joined: Fri Jul 14, 2006 8:56 am

Post 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?
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post 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
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
archivator
Earned a small fee
Earned a small fee
Posts: 14
Joined: Fri Jul 14, 2006 8:56 am

Post 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.
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post 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?
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag »

check, if you have in every included file a newline at the end of file
-tiwag
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post 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
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
User avatar
tierra
Site Admin
Site Admin
Posts: 1355
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

Post 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).
Post Reply