views:

990

answers:

4

Hi, I installed wxWidgets and then followed the instructions to make it with MSYS. After it was done, I copied a sample from a site and put it on a project in eclipse. The code was:

#include <wx/string.h>

int main(int argc, char **argv)
{
  wxPuts(wxT("A wxWidgets console application"));
}

But when I compile I get this error:

**** Build of configuration Debug for project test2 ****

**** Internal Builder is used for build               ****

g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\test2.o ..\src\test2.cpp
..\src\test2.cpp:9:23: wx/string.h: No such file or directory
..\src\test2.cpp: In function `int main(int, char**)':
..\src\test2.cpp:13: error: `wxT' was not declared in this scope
..\src\test2.cpp:13: error: `wxPuts' was not declared in this scope
..\src\test2.cpp:13: warning: unused variable 'wxT'
..\src\test2.cpp:13: warning: unused variable 'wxPuts'
Build error occurred, build is stopped
Time consumed: 78  ms.

What did I do wrong?

+1  A: 

Seems like you didn't set the correct include directories to find the wx headers (There is no -I... on the compiler command line).

You could add include directories in the project settings of a CDT project under C++->Settings->GNU C++->Include directories (or similar I don't have Eclipse running at the moment so the names way vary).

EDIT:

You have changed the "GCC Assembler" include paths. Since you don't program assembler this part isn't used. You need to edit the include paths in the "GCC C++ Compiler" path!

rstevens
I did the last thing you said but now I get a load of errors like "<thing's name here> is not defined."
Gabriele Cirulli
Since I don't know anything about wxWidgets I can only guess but maybe you missed to include some necessary files or the wxWidget stuff is located in an own namespace (if wxWidget is C++ and not plain C) so you have to use <namespace>::wxPuts(...) or using <namespace>; in your main.cpp.
rstevens
And what's the way to know the namespace it's in? Sorry, I'm a newbie
Gabriele Cirulli
It must be in the documentation. When looking at the examples from the wxWidgets homepage it seems that wxWidgets doesn't use a specific namespace but prefixes all symbols with "wx".So there must be some missing header files (you included "wx/string.h" and I assume that you need to include more to get wxPuts() to work. Take a look at the examples on the the wxWidgets homepage, they should be helpful).
rstevens
A: 
Gabriele Cirulli
You modified the wrong settings! See my edit!
rstevens
+1  A: 

Perhaps the guide here might help you, as you have already built this library I guess you only read for the section titled Verification that wxWidgets Libraries Are Working onwards.

SteveL
A: 

Maybe this will help?

T-Rex