wxWidgets 3.0.0 Error: "error: expected initializer before ':' token"

I am trying to compile a simple wxWidgets application that creates a window.

I am using LinuxMint15, so the search directory I have for the include files is wxWidgets-3.0.0/include/gtk.

In the program files, I am only including <app.h>, not <wx.h> or <wx/wx.h>.

I am getting this error in the file app.h:
error: expected initializer before ':' token


I am using Code::Blocks 12.11 currently, with the GNU GCC Compiler.

Thank you.
Last edited on
That's an error we won't be able to solve without seeing your code. My guess is that you probably typed a colon instead of a semicolon.
The file is in the wxWidgets library (in my case, wxWidgets/include/wx/gtk/app.h).

The file was coded by Robert Roebling, 1998.

Here is the Code Snippet:

1
2
3
4
5
6
7
class WXDLLIMPEXP_CORE wxApp: public wxAppBase
{
public:
    wxApp();
    virtual ~wxApp();
// rest of class…..
}
Last edited on
In the program files, I am only including <app.h>, not <wx.h> or <wx/wx.h>.


This is probably your problem. WXDLLIMPEXP_CORE is probably defined in wx.h or one of the headers it includes.

When using wx it's expected that you're going to include the main wx.h header. It sort of relies on it.

So yeah.... include wx.h first.
I am now using the include directive of:
#include <wx/wx.h>

The Search Directory is to wxWidgets-3.0.0/include.

I am getting multiple errors, among them:

Line           Message
88              error: #error "wxUSE_ANY must be defined, please read comment near the top of this file."
96              error: #error "wxUSE_COMPILER_TLS must be defined, please read comment near the top of this file."
248             error: 'wcsncpy' was not declared in this scope


There were more errors like the first 2.

Thank you for your suggestions.
#error "wxUSE_ANY must be defined, please read comment near the top of this file."


Did you try reading the comment near the top of that file?
I read the comment. I need to get the most recent version of setup.h.

I do not have a setup.h file in the wx directory. There is a setup.h file in the msvc/wx, but it is only for Windows/Microsoft Visual C++.

There is also a setup.h file in the gtk directory, but that generates the same error.

I am going to search for an up to date version of setup.h, and post here that I found it, if I do.
I got the setup.h file back in the wx folder. I am still getting the same errors.

I do not have anything linked to Code::Blocks, so if you (or anyone else) knows what to link to, that would be helpful.
Don't know whether this is your problem or not, but I had trouble compiling the wxWidget-3.0.0 samples in Code::Blocks 12.11. The following worked for me.

From docs/gtk/install.txt:
Now create your super-application myfoo.cpp and compile anywhere with

g++ myfoo.cpp `wx-config --libs --cxxflags` -o myfoo


In Code::Blocks do the following:

Project->Build options->Compiler settings->Other options - put `wx-config --cxxflags`

Project->Build options->Linker settings - under Other linker options put `wx-config --libs`
Your suggestion did not work, norm b. I think it did not because I have not build the library correctly.

I think this because I cannot enter the make and make install commands into the Terminal.

If anyone knows why this may be happening to me, I would appreciate it.

Thanks for your information, norm b (I think it will help after I build the library correctly).
CDuck wrote:
I think this because I cannot enter the make and make install commands

What you mean? Do you get a response from the shell? Maybe
bash: make: command not found

If that is the case, use your package manager to install the make package.
I think I have the make package because the make and make install commands work on the FLTK library (I would rather use wxWidgets).

According to the Terminal, There is no makefile in wxWidgets.

The Terminal also complains that I do not have certain packages installed, which I can install on my own, but running the Terminal also complains that it cannot find GTK+. I have a GTK+-3.8.0 folder in the wxWidgets folder, but the configure file cannot find it.

The main problem I am having, then, is getting the configure application to detect GTK+.
Did you use the --with-gtk configure option? doc/gtk/install.txt mentions using that option while readme.txt does not.

I followed the directions in install.txt and had no problems under Debian Sid:
mkdir buildgtk
cd buildgtk
../configure --with-gtk
make
su <type root password>
make install
ldconfig
The Terminal complains that The development files for GTK+ were not found.

Then the make command does not work:
make:   *** No targets specified and no makefile found.  Stop.
The Terminal complains that The development files for GTK+ were not found.
You need to install libgtk2.0-dev. It contains the header files for libgtk2.0.

Then the make command does not work:
If you have a configure error a makefile is not generated, as you discovered.
If there is a newer version of libgtk-dev, should I install that?

I will install libgtk2.0-dev anyway, but if there are features in 3.8.0 that are not in 2.0 that will make wxWidgets better, I would prefer to install the development files for GTK+3.8.0 (but if wxWidgets only works with 2.0, I will use that).

Thank you, norm b, for all you help.
You're welcome.

If there is a newer version of libgtk-dev, should I install that?
Yes. Looks like you need the package libgtk-3-dev.
Sorry, I ignored the "+" in your posts above. ;-)

Is GTK+ required for Gnome3? I run KDE which is Qt based so I don't even have GTK+ on my system.

I cannot answer your question because I am not that familiar with anything you have mentioned in your question. (I have not even heard of KDE until now.)

I will mark this post as solved as soon as I install the package.

Thanks again!
Last edited on
Topic archived. No new replies allowed.