GTK+中使用Glade3编程遇到Gtk-WARNING **: Could not find signal handler的问题

来源:互联网 发布:域名和ip地址绑定 编辑:程序博客网 时间:2024/06/11 09:49

首先,遇到此问题的一些必要条件:

         1.在Windows环境下开发GTK+程序

         2.使用Glade3辅助开发GTK+程序

         3.使用GtkBuilder对象读取XML文件的程序

 

其次,和此问题无关的东东:(相信看到此篇文章的不少同学,肯定GOOGLE了不短时间)

 

          1.gcc使用-export-dynamic选项

          2.pkg-config读取gmodule的配置

 

 

最后是解决方法:

          在相应的信号处理回调函数前,增加G_MODULE_EXPORT声明,当然了,要保证回调函数的返回值和参数,和API文档上相应SIGNAL或者EVENT的回调要一致!

           PS:为了这个问题,我可是GOOGLE了将近一下午,后来没办法,干脆去研究gtk_builder_connect_signals()函数,

结果在API文档上看到的NOTE就是:

           When compiling applications for Windows, you must declare signal callbacks with G_MODULE_EXPORT, or they will not be put in the symbol table. On Linux and Unices, this is not necessary; applications should instead be compiled with the -Wl,--export-dynamic CFLAGS, and linked against gmodule-export-2.0.

            汗死。。。