wxApp not recognized ?

124 views
Skip to first unread message

m3d

unread,
Jun 15, 2011, 6:35:48 PM6/15/11
to wx-u...@googlegroups.com

Hi,

I am a noob using wxwidget (so I probably made something wrong...), but have
to deal with customer code using it and strangely it does not work. After
(literally) hours googling back and forth, I've decided to come here.

My Environment
I am using CentOs [Red Hat 4.1.2] with gcc 4.1.2
I've just downloaded wxwidgets 2.9.1 using the .tar.bz, and followed the
instructions on the install.txt:
./configure --with-motif
make
su
make install
ldconfig
exit
It worked fine, without error

My Project
I have edited my Makefile to account for WXHOME, WXINCL = $(WXHOME)/include
and WXLIBS = -L$(WXHOME)/lib.
As well, I have added -I$(WXINCL) and -$(WXLIBS) to the make "itself".
In my main.cpp, I have :

#include <wx/wx.h>
#include <wx/app.h>

Then my code.

At this point, when I build everything the files wx/... are recognized and
included : nice.

My Issue
wxApp is not recognized:

If my code contains a wxApp object in my main (wxApp myapp = wxApp();), I am
returned a Missing ';' after 'wxApp' error.
If my code contains a class definition with an inheritage to wxApp (class
Myclass:public wxApp{ /* bla */};), I am returned an Expected class-name
before '{' token error.


I know there is something wrong in my configuration, which makes the wx
headers files includable but not "reachable", but I don't know what I
missed....

Thanks a lot for helping,
m3d
--
View this message in context: http://old.nabble.com/wxApp-not-recognized---tp31855829p31855829.html
Sent from the wxWidgets - Users mailing list archive at Nabble.com.

Igor Korot

unread,
Jun 15, 2011, 6:57:14 PM6/15/11
to wx-u...@googlegroups.com
Hi,
Sorry for top posting.

1. Do you have to build with motif? You will have more luck with "--with-gtk".
2. It is much better to build wx this way:
a) wget wxWidgets-X.Y.Z..tar.bz
b) tar xjvf wxWidgets-X.Y.Z.tar.bz -C wxWidgets
c) cd wxWidgets
d) mkdir buildGTK
e) ../configure
f) make && make install
3. Please look at the samples directory. There you will see
a lot of code that will show how to use wxWidgets.
4. If you go to wxWidgets/buildGTK/samples/minimal and issue
"make" command you will see how to properly build wx program.
Just try to make you program compilation the same.

The first question is because there is not too many people who
uses Motiff port. You will find much more support for wxGTK.

Thank you.

> --
> Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
>
> To unsubscribe, send email to wx-users+u...@googlegroups.com
> or visit http://groups.google.com/group/wx-users

Vadim Zeitlin

unread,
Jun 16, 2011, 7:44:00 AM6/16/11
to wx-u...@googlegroups.com
On Wed, 15 Jun 2011 15:35:48 -0700 (PDT) m3d <flo...@int.com> wrote:

m> I've just downloaded wxwidgets 2.9.1 using the .tar.bz, and followed the
m> instructions on the install.txt:
m> ./configure --with-motif

Are you sure that you want to use wxMotif port? It's old and barely
maintained, you'd be much better off with wxGTK port (which is the default
or can be selected explicitly with --with-gtk configure option).

m> My Project
m> I have edited my Makefile to account for WXHOME, WXINCL = $(WXHOME)/include
m> and WXLIBS = -L$(WXHOME)/lib.

You shouldn't do this. Use `wx-config --cxxflags` instead of $(WXINCL) and
`wx-config --libs` instead of $(WXLIBS).

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

m3d

unread,
Jun 16, 2011, 11:45:51 AM6/16/11
to wx-u...@googlegroups.com

Hi Vadim, (thanks Igor as well for your answered).

I've uninstalled wx and reinstalled it with the gtk configuration, as you
recommended me to.

I've also changed my makefile so instead of having:

MyProject: MyProject.cpp
$(CC) $(SCFLAGS) $(CPLUSFLAG) $(DEBUG) -I$(OWINCL)\
-o MyProject MyProject.cpp $(LDFLAGS) $(STATIC_LINK) $(WXLIBS)

I now have:

MyProject: MyProject.cpp
$(CC) $(SCFLAGS) $(CPLUSFLAG) $(DEBUG) -Iwx-config--cxxflags\
-o MyProject MyProject.cpp $(LDFLAGS) $(STATIC_LINK) wxconfig--libs


Good new: instead of having 400+ errors when compiling, I now only have 3.
Bad new: out of those 3, 2 are "wx/filename.h: No such file or directory".
The 3rd one is then logical: without wx.h, and app.h, the wxApp class is not
recognized so I have this "expected class name before { token" error...
:(

I guess I didn't made the substitutions the way you expected me to do :(

Thanks a lot,
m

--
View this message in context: http://old.nabble.com/wxApp-not-recognized---tp31855829p31861929.html

Vadim Zeitlin

unread,
Jun 16, 2011, 12:05:05 PM6/16/11
to wx-u...@googlegroups.com
On Thu, 16 Jun 2011 08:45:51 -0700 (PDT) m3d <flo...@int.com> wrote:

m> MyProject: MyProject.cpp
m> $(CC) $(SCFLAGS) $(CPLUSFLAG) $(DEBUG) -I$(OWINCL)\
m> -o MyProject MyProject.cpp $(LDFLAGS) $(STATIC_LINK) $(WXLIBS)
m>
m> I now have:
m>
m> MyProject: MyProject.cpp
m> $(CC) $(SCFLAGS) $(CPLUSFLAG) $(DEBUG) -Iwx-config--cxxflags\
m> -o MyProject MyProject.cpp $(LDFLAGS) $(STATIC_LINK) wxconfig--libs
...
m> I guess I didn't made the substitutions the way you expected me to do :(

No. The backticks that I used here:

m> > You shouldn't do this. Use `wx-config --cxxflags` instead of $(WXINCL)
m> > and `wx-config --libs` instead of $(WXLIBS).

mean that you must use the output of this command. With GNU make it would
be $(wx-config --cxxflags).

m3d

unread,
Jun 16, 2011, 12:35:26 PM6/16/11
to wx-u...@googlegroups.com

thanks for the clarification.
So I've typed wx-config--cxxflags in a shell, and paste the return in my
makefile instead of the -I$(WXINCL), same for wx-config--libs instead of
$(WXLIBS).

It now works perfectly (well, I still have errors but those are code errors
I can handle).

Thanks a lot for your help!

Regards,
m

--
View this message in context: http://old.nabble.com/wxApp-not-recognized---tp31855829p31862424.html

Reply all
Reply to author
Forward
0 new messages