我安装了wxWidgets,然后按照说明使用MSYS。完成后,我从一个站点复制了一个样本并将其放在eclipse中的一个项目中。代码是:
#include <wx/string.h>
int main(int argc, char **argv)
{
wxPuts(wxT("A wxWidgets console application"));
}
但是当我编译时,我得到了这个错误:
**** 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.
我做错了什么?
我编辑了设置,但我还是得到了这个。 没有 - 我还是..
**** Build of configuration Debug for project Wx1 ****
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\simple.o ..\src\simple.cpp
In file included from ..\src\simple.cpp:1:
..\src\simple.h:1:19: wx/wx.h: No such file or directory
In file included from ..\src\simple.cpp:1:
..\src\simple.h:4: error: expected class-name before '{' token
..\src\simple.h:6: error: expected `,' or `...' before '&' token
..\src\simple.h:6: error: ISO C++ forbids declaration of `wxString' with no type
..\src\simple.cpp:3: error: expected `,' or `...' before '&' token
..\src\simple.cpp:4: error: ISO C++ forbids declaration of `wxString' with no type
..\src\simple.cpp: In constructor `Simple::Simple(int)':
..\src\simple.cpp:4: error: class `Simple' does not have any field named `wxFrame'
..\src\simple.cpp:4: error: `NULL' was not declared in this scope
..\src\simple.cpp:4: error: `wxID_ANY' was not declared in this scope
..\src\simple.cpp:4: error: `title' was not declared in this scope
..\src\simple.cpp:4: error: `wxDefaultPosition' was not declared in this scope
..\src\simple.cpp:4: error: `wxSize' was not declared in this scope
..\src\simple.cpp:6: error: `Centre' was not declared in this scope
..\src\simple.cpp:6: warning: unused variable 'Centre'
..\src\simple.cpp:4: warning: unused variable 'NULL'
..\src\simple.cpp:4: warning: unused variable 'wxID_ANY'
..\src\simple.cpp:4: warning: unused variable 'title'
..\src\simple.cpp:4: warning: unused variable 'wxDefaultPosition'
..\src\simple.cpp:4: warning: unused variable 'wxSize'
Build error occurred, build is stopped
Time consumed: 63 ms.
这是截图 screenshot http://imgkk.com/i/aRjvDe.jpg
我做错了什么?
答案 0 :(得分:2)
好像你没有设置正确的include目录来查找wx头文件(编译器命令行上没有-I ...)。
你可以在C ++下的CDT项目的项目设置中添加包含目录 - > gt> Settings-&gt; GNU C ++ - &gt; Include目录(或类似我目前没有Eclipse运行所以名称方式不同)。
修改
您已更改“GCC Assembler”包含路径。由于您没有编译汇编程序,因此不使用此部分。您需要在“GCC C ++编译器”路径中编辑包含路径!
答案 1 :(得分:1)
也许指南here可能会对您有所帮助,因为您已经构建了这个库,我想您只读了标题为验证wxWidgets库正在工作以后的部分。