在GTK下编译wxWidgets2.8.10错误的问题

在上文提到的在Linux下编译wxWidgets库的过程中出现报错。


方案:

wxWidgets版本:wxWidgets2.8.10

GTK版本:Ubuntu11.04

编译器:GCC4.5


报错的具体内容:

./include/wx/gsocket.h:40: error: usingtypedef-name ‘GSocket’ after ‘class’
/usr/include/glib-2.0/gio/giotypes.h:120: error: ‘GSocket’ has a previousdeclaration here
In file included from ../include/wx/gsocket.h:179,
from ../src/gtk/gsockgtk.cpp:21:
../include/wx/unix/gsockunx.h:40: error: using typedef-name ‘GSocket’ after‘class’
/usr/include/glib-2.0/gio/giotypes.h:120: error: ‘GSocket’ has a previousdeclaration here
../src/gtk/gsockgtk.cpp: In function ‘void _GSocket_GDK_Input(void*, gint,GdkInputCondition)’:
../src/gtk/gsockgtk.cpp:34: error: ‘struct _GSocket’ has no member named‘Detected_Read’
../src/gtk/gsockgtk.cpp:36: error: ‘struct _GSocket’ has no member named‘Detected_Write’
../src/gtk/gsockgtk.cpp: In member function ‘virtual boolGSocketGUIFunctionsTableConcrete::Init_Socket(GSocket*)’:
../src/gtk/gsockgtk.cpp:56: error: ‘struct _GSocket’ has no member named‘m_gui_dependent’
../src/gtk/gsockgtk.cpp:57: error: ‘struct _GSocket’ has no member named‘m_gui_dependent’
../src/gtk/gsockgtk.cpp: In member function ‘virtual voidGSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket*)’:
../src/gtk/gsockgtk.cpp:67: error: ‘struct _GSocket’ has no member named‘m_gui_dependent’
../src/gtk/gsockgtk.cpp: In member function ‘virtual voidGSocketGUIFunctionsTableConcrete::Install_Callback(GSocket*, GSocketEvent)’:
../src/gtk/gsockgtk.cpp:72: error: ‘struct _GSocket’ has no member named ‘m_gui_dependent’
../src/gtk/gsockgtk.cpp:75: error: ‘struct _GSocket’ has no member named ‘m_fd’
../src/gtk/gsockgtk.cpp:83: error: ‘struct _GSocket’ has no member named‘m_server’
../src/gtk/gsockgtk.cpp:90: error: ‘struct _GSocket’ has no member named ‘m_fd’
../src/gtk/gsockgtk.cpp: In member function ‘virtual voidGSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket*, GSocketEvent)’:
../src/gtk/gsockgtk.cpp:98: error: ‘struct _GSocket’ has no member named‘m_gui_dependent’
../src/gtk/gsockgtk.cpp:108: error: ‘struct _GSocket’ has no member named‘m_server’
make: *** [coredll_gtk_gsockgtk.o] 错误 1


借助谷歌发现之前有人遇到过类似的问题,症结在于gtk+与wxWindgets2.8.10中共同定义了 GSocket。


修改gtk+显然不太合适,所以就改wxWidgets咯,修改一下wxWidgets的源代码:

位置是根目录下的src/gtk/gsockgtk.cpp

Index: 2.8/src/gtk/gsockgtk.cpp
===================================================================
--- 2.8/src/gtk/gsockgtk.cpp (revision 60599)
+++ 2.8/src/gtk/gsockgtk.cpp (working copy)
@@ -15,8 +15,13 @@
#include 
#include 

+// newer versions of glib define its own GSocket but we unfortunately use this
+// name in our own (semi-)public header and so can't change it -- rename glib
+// one instead
+#define GSocket GlibGSocket
#include 
#include 
+#undef GSocket

#include "wx/gsocket.h"
#include "wx/unix/gsockunx.h"


 
  
define和undef部分是新添加的,将GSocket重命名为GlibSocket就可以避免同名了。


重新编译,实测成功!




你可能感兴趣的:(wxwidgets学习)