![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2
![]() |
wxWidgets problem
Hey guys!
Mmm, i just installed wxWidgets 2.8.4 - it's the first time i've used it... im running Fedora 4. I installed it using: COMPILING USING CONFIGURE ========================= * The simplest case ------------------- If you compile wxWidgets on Linux for the first time and don't like to read install instructions just do (in the base dir): > ./configure --with-x11 > make > su <type root password> > make install > ldconfig > exit all went fine - but when i tried to create this app from this tutorial: http://www.bzzt.net/~wxwidgets/icpp_wx1.html it didnt compile - however i could compile the samples included with the wxWidgets package just fine... i get this error: ...
/usr/local/include/wx-2.8/wx/scrolwin.h:55: note: wxScrollHelper::wxScrollHelper(wxWindow*)
/usr/local/include/wx-2.8/wx/sizer.h: In member function ‘void wxSizerItem::SetMinSize(const wxSize&)’:
/usr/local/include/wx-2.8/wx/sizer.h:285: error: invalid use of undefined type ‘struct wxWindow’
/usr/local/include/wx-2.8/wx/utils.h:51: error: forward declaration of ‘struct wxWindow’
basic.h: At global scope:
basic.h:4: error: expected class-name before ‘{’ token
basic.h:4: warning: ‘class BasicApplication’ has virtual functions but non-virtual destructor
basic.h:9: error: invalid use of undefined type ‘struct wxFrame’
/usr/local/include/wx-2.8/wx/log.h:538: error: forward declaration of ‘struct wxFrame’
basic.cpp: In function ‘wxAppConsole* wxCreateApp()’:
basic.cpp:4: error: cannot convert ‘BasicApplication*’ to ‘wxAppConsole*’ in return
basic.cpp: In function ‘BasicApplication& wxGetApp()’:
basic.cpp:4: error: ‘wxApp’ has not been declared
basic.cpp:4: error: ‘GetInstance’ was not declared in this scope
basic.cpp: In member function ‘virtual bool BasicApplication::OnInit()’:
basic.cpp:9: error: ‘class BasicFrame’ has no member named ‘Show’
basic.cpp:10: error: ‘SetTopWindow’ was not declared in this scope
basic.cpp:12: error: expected ‘;’ before ‘:’ token
basic.cpp:12: error: expected primary-expression before ‘:’ token
basic.cpp:12: error: expected `;' before ‘:’ token
basic.cpp: In constructor ‘BasicFrame::BasicFrame(const wxChar*, int, int, int, int)’:
basic.cpp:16: error: type ‘struct wxFrame’ is not a direct base of ‘BasicFrame’
make: *** [basic.o] Error 1obviously its not linking - i've set the $LD_LIBRARY_PATH to include /usr/local/lib which is where wxWidgets libraries are located... i added -I/usr/local/include/wx-2.8/ to get the includes - but then gave more errors on linking. i didnt play around with the $LIBS variable in the Makefile (i.e. -L/usr/local/lib/) because im not very familiar with linking... the flags are very foreign to me, its actually a little scary! here is the full code: // basic.h
#ifndef BASIC_H
#define BASIC_H
class BasicApplication : public WxApp {
public:
virtual bool OnInit();
};
class BasicFrame : public wxFrame {
public:
BasicFrame(const wxChar *title,int xpos,int ypos,int width,int height);
~BasicFrame();
};
#endif// basic.cpp
#include <wx/wx.h>
#include "basic.h"
IMPLEMENT_APP(BasicApplication);
bool BasicApplication::OnInit() {
BasicFrame *frame = new BasicFrame("basic",50,50,450,300);
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE:
}
BasicFrame::BasicFrame(const wxChar *title,int xpos,int ypos,int width,int height)
: wxFrame((wxFrame *)NULL,-1,title,wxPoint(xpos,ypos),wxSize(width,height)) {}
BasicFrame::~BasicFrame() {}// basic_resources.rc #include "wx/msw/wx.rc" // Makefile
PROGRAM = basic
OBJECTS = ${PROGRAM}.o ${PROGRAM}_resources.o
RC = windres.exe
CC = g++
INCLUDES = -I/usr/local/include/wx-2.8/
CCSW1 = --pipe -fvtable-thunks -c -D_X86_=1 -DWIN32 -D_WIN32 -DWINVER=0x0400 -D__WIN95__ \
-D__GNUWIN32__ -D__WIN32__ -DSTRICT -D__WXMSW__ -D__WINDOWS__\
-Wall -fno-pcc-struct-return -O2 -fno-rtti -fno-exceptions
CCSW2 = --pipe -fvtable-thunks -Wl,--subsystem,windows -mwindows
LIBS = -lwx -lxpm -lcomctl32 -ladvapi32 -lwsock32 -lole32 -loleaut32 -luuid
RESSW = --include-dir c:/gcc-2.95.2-1/i386-mingw32msvc/include \
--define __WIN32__ --define __WIN95__ --define __GNUWIN32__
.SUFFIXES: .o .cpp
all: ${OBJECTS}
$(CC) -o $(PROGRAM) ${OBJECTS} ${CCSW2} ${LIBS}
.cpp.o:
$(CC) ${CCSW1} ${INCLUDES} -c -o $@ $<
${PROGRAM}_resources.o:
$(RC) ${RESSW} ${PROGRAM}.rc $@
.PHONY : clean
clean:
echo cleaning up
rm $(OBJECTS)
rm *.$$$$$$
rm ${PROGRAM}.exei hope someone can help! any response will be much appreciated! ![]() |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2006
Location: Ohio
Posts: 93
Rep Power: 3
![]() |
You need to include wx.h in your header file so that the wx classes are recognizable in that file.
If you get a linker error talking about "duplicate resources," you need to comment out the wx.rc include line.
__________________
Neeley.org |
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2
![]() |
mmm - didnt seem to work! :/
ill have a good look at the samples included and see whats missing! ill post back if im still stuck! thanks for help! ![]() |
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
Lets make this easy on you, when on Linux you should not do X11 you should do wxGTK (that would be --with-gtk). Once you have that done you should use the wx-config tool, not hard code all the options. This means you can build program with this simple command line:
g++ myapp.cpp `/usr/local/bin/wx-config --libs --cflags` Also you have a lot of "msw" type path and even a windows *.exe file doesn't make much sense on Linux.
__________________
Robotics @ Maryland AUV Team - Software Lead |
|
|
|
|
|
#5 |
|
Professional Programmer
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2
![]() |
guys i have no idea what im doing here! i always have trouble iwth GUIs they give me a headache all that macro crap and whatnot!
ok - why mustn't i use X11??? i know GTK is another windowing system - but not all distros have it? but they all certainly have X11 right? mmm, i didnt get a chance to work on this this weekend - gonna try look at it between work, so busy these days :/ |
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
GTK is much better supported and maintained then the port X11. You don't want to run into trouble that is due to bugs in the library. All distros have GTK. GTK is the GUI toolkit used by GIMP, Gaim and the Gnome desktop. Even KDE based distros have GTK because lots of linux apps are written with GTK.
__________________
Robotics @ Maryland AUV Team - Software Lead |
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2
![]() |
ok coolio! thanks for the advice man... sure didnt know that stuff!
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| <td> height problem | grimpirate | HTML / XHTML / CSS | 19 | May 4th, 2007 6:01 AM |
| Stuck with a C problem | Polaris | C++ | 8 | Aug 19th, 2006 3:30 PM |
| wxWidgets Size Problem. | HackeZ | C++ | 13 | Feb 7th, 2006 9:32 PM |
| cgi/perl script + IE problem | joyceshee | Perl | 2 | Jan 24th, 2006 11:10 AM |
| help with recursion problem | the_new_guy_in_town | Java | 3 | Apr 7th, 2005 3:04 AM |