解决方案1:
在GCC编译命令中加入-export-dynamic,如:
gcc test.c callbacks.c -o test `pkg-config --libs --cflags libglade-2.0 ` -export-dynamic
解决方案2:
在GCC编译命令中使用pkg-config加入库gmodule-export-2.0,如:
gcc test.c callbacks.c -o test `pkg-config --libs --cflags libglade-2.0 gmodule-export-2.0`
问题原因,以下是libglade说明里的一段原话。
Note If you wish to autoconnect handlers defined in the main executable (not a shared library), you will need to pass a linker flag to export the executable's symbols for dynamic linking. This flag is platform specific, but libtool can take care of this for you. Just add -export-dynamic argument to your link flags, and libtool will convert it to the correct format. The easiest way to get the correct extra flags is to check for gmodule-export-2.0 with pkg-config.
疑问:为什么?
need to pass a linker flag to export the executable's symbols for dynamic linking
一种回答:
Libglade can also automatically connect signal handlers in the user interface. It does this by matching handler names specified in the glade file with symbols in the executable looked up with the gmodule library (this requires that
applications be linked with the --export-dynamic flag).
本文介绍了在使用GCC编译器进行编译时如何通过添加特定的链接器标志来实现动态链接,这对于需要自动连接信号处理器的应用尤为重要。文章提供了两种解决方法:一是直接在GCC编译命令中加入-export-dynamic;二是使用pkg-config加入gmodule-export-2.0库。
1万+

被折叠的 条评论
为什么被折叠?



