【问题标题】:Using WxWidgets with Eclipse for C++在 C++ 的 Eclipse 中使用 WxWidgets
【发布时间】:2009-09-06 10:13:40
【问题描述】:

我安装了 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

我做错了什么?

【问题讨论】:

    标签: eclipse wxwidgets


    【解决方案1】:

    似乎您没有设置正确的包含目录来查找 wx 标头(编译器命令行上没有 -I...)。

    您可以在 C++->Settings->GNU C++->Include 目录下的 CDT 项目的项目设置中添加包含目录(或类似的,我目前没有运行 Eclipse,因此名称会有所不同)。

    编辑:

    您已更改“GCC 汇编程序”包含路径。由于您不编写汇编程序,因此不使用此部分。您需要在“GCC C++ Compiler”路径中编辑包含路径!

    【讨论】:

    • 我做了你说的最后一件事,但现在我收到很多错误,例如“ is not defined。”
    • 由于我对 wxWidgets 一无所知,我只能猜测,但也许你错过了包含一些必要的文件,或者 wxWidget 的东西位于自己的命名空间中(如果 wxWidget 是 C++ 而不是纯 C)所以你必须使用 ::wxPuts(...) 或使用 ;在你的 main.cpp 中。
    • 知道它所在的命名空间的方法是什么?对不起,我是新手
    • 必须在文档中。查看 wxWidgets 主页上的示例时,似乎 wxWidgets 没有使用特定的命名空间,而是在所有符号前加上“wx”。所以必须有一些丢失的头文件(你包括“wx/string.h”,我假设你需要包括更多才能让 wxPuts() 工作。看看 wxWidgets 主页上的示例,它们应该是有帮助)。
    【解决方案2】:

    也许here 指南可能会对您有所帮助,因为您已经构建了这个库,我猜您只阅读了标题为验证 wxWidgets 库是否正常工作的部分。

    【讨论】:

      猜你喜欢
      • 2012-03-09
      • 1970-01-01
      • 1970-01-01
      • 2010-09-16
      • 1970-01-01
      • 2020-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多