wxWidgets build errors (with C++)

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

wxWidgets build errors (with C++)

Postby nerdmaster » Sat Dec 23, 2006 9:46 pm

I've been checking various guides for developing GUIs with wxWidgets and even the simplest example code refuses to compile.

For example, simply including wx/wx.h causes several pages of errors:

/usr/include/wx/chkconf.h:47:9: error: #error "wxUSE_DYNLIB_CLASS must be defined."
/usr/include/wx/chkconf.h:55:9: error: #error "wxUSE_FILESYSTEM must be defined."
/usr/include/wx/chkconf.h:68:9: error: #error "wxUSE_DYNAMIC_LOADER must be defined."
/usr/include/wx/chkconf.h:76:9: error: #error "wxUSE_LOG must be defined."

to name a few.

Can anyone suggest any posible causes/solutions?
nerdmaster
 
Posts: 52
Joined: Thu Jul 14, 2005 10:18 am

RE: wxWidgets build errors (with C++)

Postby jjmac » Sun Dec 24, 2006 8:11 am

Do a grep on those names, throuout the wx headers you have ...

]$ grep -l *.h

And any subdirectories, to find the headers that their defined in ... Its been a long time since i did anything with wxwindows but i remember it was a good environment. Basically some header(s) just need inclusion that it would seem wx/wx.h is autoing.

Have you got the 'samples' directory handy, that should show up all the neccessary include files needed.

Have a look at the way the Makefile is arranged too. If i'm remembering correctly, wxwindows uses a somewhat tricky Makefile, one that references others depending on what OS it is running on. I can remember most of my problems were solved from tweaks with in that file.


jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia

RE: wxWidgets build errors (with C++)

Postby nerdmaster » Sun Dec 24, 2006 4:56 pm

Unfortunately I don't know where the headers are, seeing as I installed it through yum
nerdmaster
 
Posts: 52
Joined: Thu Jul 14, 2005 10:18 am

RE: wxWidgets build errors (with C++)

Postby jjmac » Mon Dec 25, 2006 8:24 am

Check the man/doc info on the package system, there will likely be a switch to list the file set. Likely locations would be,

/usr/include/wx
/usr/local/include/wx
/usr/lib/wx


jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia

Postby nerdmaster » Thu Dec 28, 2006 7:21 pm

I've uninstalled all the packages, and this time only installed the wxGTK and wxGTK-devel (with the wxGTK-GL as a dependancy) and that seems to have solved most of the problems. Now it's a different problem. The following code:

#include <wx-2.6/wx/wx.h>

class MyApp: public wxApp
{
virtual bool OnInit();
};

Produces this error:

error: expected class-name before ‘{’ token
nerdmaster
 
Posts: 52
Joined: Thu Jul 14, 2005 10:18 am

Postby jjmac » Thu Dec 28, 2006 8:27 pm

Howdy,

>>
and this time only installed the wxGTK and wxGTK-devel (with the wxGTK-GL as a dependancy)
>>

Sounds like you may have had a cross mix originally.
Make sure all the wxGTK packages are in, and of course the core package. When i was doing wxwindows it was in RH 5.0 or 6.0 i think. Originally in windows though. In Linux it was via a src compile/install, so i only needed the core tarball along with the GTK tarball. There were a couple of those. And the appropriate gtk packages needed to be present as well. From there it didn't give me any real problems. Except for some confusion i had with the Makefiles ... but i guess it may be different now, as the headers were all in /usr/include/wx then. No versioning involved.


>>
error: expected class-name before ‘{’ token
>>

Yep, one of those 'wtf' type of errors that can drive a person crazy. I would say that it can't resolve the referance to wxApp.

Which means a search through the includes in wx/wx.h, for wxApp, looking for the 'path' descrepancy. Look for possible 'case' differences too. Like WX/header.h rather than wx/header.h ... that can happen. And is a bug. Not ignoring how the Makefile(s) are arranged either.

I'll try and put wxwindows in over the week end, as i've been meaning to ever since seeing it on the dvd a number of issues back. Just to see how it's progressed. Once up and running it was quite a good environment. But i thought it suffered from trying to cover to much in the way of 'so called' portability all in the one core package. By that i mean bending to much to MS requirments, which caused irritating syntax bugs to crop up at time, mainly involving 'case' issues.

In any case, i would suspect it is just a 'path' problem. And likely involving the resolution of whatever header contains 'wxApp'.


jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia

Postby jjmac » Fri Dec 29, 2006 11:50 pm

-=--=- Just unpacked the source -=-=-


It used to be called wxWindows or my memory is going bent. Might be just that i came across it first in win. In any case found the

.../Essentials/wxWidgets/wxGTK-2.6.2.tar.bz2

source on the June 2006 dvd (lxf80D) disc. And am just about to compile it up. But have been looking over it first for the wxApp declaration.

================================================
The below has been completely re-edited after installing and testing some samples.
Sun 31/12
================================================

>>
#include <wx-2.6/wx/wx.h>
>>

The 'wx-2.6' part is causing the problem. It should be just,

#include <wx/wx.h>

The include path will be provided by
Code: Select all
wx-config --cxxflags --libs


The actual class 'wxApp' is defined in 'wx/gtk/wxapp.h' from 'wx/app.h' from 'wx/wx.h'

You'll notice in wx/app.h

Code: Select all
// -------------------------------------------------------
// now include the declaration of the real class
// -------------------------------------------------------

#if wxUSE_GUI
    #if defined(__WXPALMOS__)
        #include "wx/palmos/app.h"
    #elif defined(__WXMSW__)
        #include "wx/msw/app.h"
.
.
.
    #elif defined(__WXGTK__)
        #include "wx/gtk/app.h"
.
.
.


The required macro along with the approprieate include path for your install, will be returned by

Code: Select all
'wx-config --cxxflags'


As the install text file suggests, as for a command line ...

Code: Select all
g++ myfoo.cpp `wx-config --cxxflags --libs` -o myfoo


Should be all thats needed. Or as a basic Makefile you could do ...

Code: Select all
# Basic wxwindows/wxWidgets Makefile

default:
   g++ $(shell wx-config --cxxflags) $(shell wx-config --libs ) minimal.cpp -o minimal



That can be elaborated on by expanding the wx-config return if wanted ...

Code: Select all

]$ wx-config --cxxflags
-I/usr/local/wxGTK/lib/wx/include/gtk2-ansi-release-2.6 -I/usr/local/wxGTK/include/wx-2.6 -DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_LARGEFILE_SOURCE=1

]$ wx-config --libs
-L/usr/local/wxGTK/lib -pthread   -L/usr/X11R6/lib  -lwx_gtk2_xrc-2.6 -lwx_gtk2_qa-2.6 -lwx_gtk2_html-2.6 -lwx_gtk2_adv-2.6 -lwx_gtk2_core-2.6 -lwx_base_xml-2.6 -lwx_base_net-2.6 -lwx_base-2.6


wx-config will adjust its' out put depending on where it's been installed to.

And depending on where you installed too, you may need to adjust the PATH variable along with an addition to the /etc/ld.so.config file. Lickely only if installed to a none standard place though


jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia

Postby nerdmaster » Wed Jan 03, 2007 2:46 pm

Thanks for the help, although the makefile format you suggested, started throwing up errors. I've found that it will compile with these changes:

Code: Select all
default:
   g++ minimal.cpp $(shell wx-config --cxxflags) $(shell wx-config --libs ) -o minimal


Although this seems to have opened a new can of worms, producing this error when trying to run the compiled program:

./minimal: error while loading shared libraries: libwx_gtk2_aui-2.8.so.0: cannot open shared object file: No such file or directory
nerdmaster
 
Posts: 52
Joined: Thu Jul 14, 2005 10:18 am

Postby jjmac » Thu Jan 04, 2007 10:59 am

Howdy


Your cli is essentially the same, i know you know the layout but just for general clarity ...

Makefile format:
Code: Select all

<target>: <optional depends/target>
< a tab char><cli(s)>
<blank line>


Not sure why that didn't work ...

>>
./minimal: error while loading shared libraries: libwx_gtk2_aui-2.8.so.0: cannot open shared object file: No such file or directory
>>

I compiled mine in a seperate build directory branching off the top level source directory. Changed directory into it an ran configure with ...

Code: Select all
]$ ../configure --prefix=/usr/local/wxGTK --with-gtk=2


From there i just ran 'make'

Code: Select all
]$ make 2>&1 |tee zmake-out.log


I then created /usr/local/wxGTK, and made the top level directory hierarchy in that directory. Then ran 'make install' fom the build directory after changing to root.

Code: Select all
]$ su
Password:
xxxxxxxxxxxxxxx
]# make install 2>&1 |tee zinst-out.log


Then edited my /etc/ld.so.config in an editor invoked from my root shell. And added an entry to ...

Code: Select all
/usr/local/wxGTK/lib


Still in the root shell, ran 'ldconfig' to update the .so libs cached paths.

Code: Select all
]# ldconfig


Works fine, i just have to add the path to /usr/local/wxGTK/bin to the shell i'm in before hand to work with it.

It looks like you have the recent version, i saw that on the wxWindows/wxWidget site. I'm using version 2.6.2 from lxf June 2006. It dosen't include the DialogED program which should be in the 'utils' directory in the source. I managed to dig out the version from '2.2.9'. Which is few years old. No need to mention, it is on the primative side as designers go. And had i had to compile the whole 2.2.9 source to get access to the 'DialogED' tool. I only installed its' .so libs though, not the whole lot.

Did the 2.8 version of wxGTK that you have include the 'DialogED' facility ???

It should have been in the utils/dialoged directory hanging off the main source tree.

No decent designer makes wxWidget guis' a hard thing to construct.


I figure your library problem is probably just a missiing entry in the 'ld.so.config' file and running 'ldconfig' to update the cache. Don't be tempted to set the LD_LIBRARY' variable, or whatever it's called. It's a legacy method, and has been known to cause problems. Using the file is better.

wxWindows/Widgets is certainly macro heaven, is it not :)


jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests