Ubuntu中CodeBlocks开发wxWidgets项目发生wxIsBusy等没有定义的问题

如果你在Ubuntu中用CodeBlocks编译wxWidgets工程遇到类似以下错误,可以尝试本文提供的解决办法:

错误现象:

/usr/include/wx/cursor.h: In constructor 'wxBusyCursorSuspender::wxBusyCursorSuspender()': 
/usr/include/wx/cursor.h:65: error: 'wxIsBusy' was not declared in this scope 
/usr/include/wx/cursor.h:67: error: 'wxBusyCursor' has not been declared 
/usr/include/wx/cursor.h:67: error: 'wxSetCursor' was not declared in this scope 
/usr/include/wx/cursor.h: In destructor 'wxBusyCursorSuspender::~wxBusyCursorSuspender()': 
/usr/include/wx/cursor.h:72: error: 'wxIsBusy' was not declared in this scope 
/usr/include/wx/cursor.h:74: error: 'wxBusyCursor' has not been declared 
/usr/include/wx/cursor.h:74: error: 'wxSetCursor' was not declared in this scope 
/usr/include/wx/region.h: In member function 'bool wxRegionBase::Intersect(const wxRect&)': 
/usr/include/wx/region.h:251: error: invalid use of undefined type 'struct wxRegion' 
/usr/include/wx/gdicmn.h:38: error: forward declaration of 'struct wxRegion' 
/usr/include/wx/region.h: In member function 'bool wxRegionBase::Subtract(const wxRect&)': 
/usr/include/wx/region.h:256: error: invalid use of undefined type 'struct wxRegion' 
/usr/include/wx/gdicmn.h:38: error: forward declaration of 'struct wxRegion' 
/usr/include/wx/region.h: In member function 'bool wxRegionBase::Xor(const wxRect&)': 
/usr/include/wx/region.h:261: error: invalid use of undefined type 'struct wxRegion' 
/usr/include/wx/gdicmn.h:38: error: forward declaration of 'struct wxRegion' 

原因分析:
如果确认你已经安装了图形UI库(如GTK),这一般是因为wx-config中的配置指向错误造成的。

解决办法:
1.确定你正常安装了CodeBlocks以及wxWidgets,可以参考以下步骤

安装基本编译环境
sudo apt-get install build-essential gdb
 
安装CodeBlocks
sudo apt-get install codeblocks codeblocks-dbg wxformbuilder
 
安装wxWidgets
sudo apt-get install libwxbase2.8 libwxbase2.8-dev libwxgtk2.8-0 libwxgtk2.8-dev libwxgtk2.8-dbg wx-common wx2.8-headers wx2.8-i18n

2.确认当前wxWidgets版本,选择gtk2-unicode-debug-2.8:

sudo update-alternatives –config wx-config

3.修改wx-config配置,让它指向到2上所选的正确版本gtk2-unicode-debug-2.8:

wx-config –cxxflags -I /usr/lib/wx/include/gtk2-unicode-debug-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_LARGEFILE_SOURCE=1 -D__WXDEBUG__ -D__WXGTK__ -pthread

 



郑重声明:
除特别声明为转载内容外,本站所有内容均为作者原创,谢绝任何单位和个人不经许可的复制和转播!
对于确有转载需要的,请先与作者联系,在获得允许后烦请在转载时保留文章出处。
本文出自Lupin's Blog:http://www.cnzui.com/archives/1189