我为此使用和开发了wxWebConnect和Python绑定(bind)(请参阅http://github.com/jonmmorgan/wxwebconnect/http://github.com/jonmmorgan/pywebconnect/)。这些以前建立在Linux上。但是,当添加了对XRC处理程序的支持时,加载带有以下错误的.so文件时,Python程序将崩溃:

undefined symbol: _ZN22wxWebControlXmlHandlerC1Ev

自从进行更改以支持XRC以来,该库已经构建并可以在Mac OS X和Windows上正常运行。

造成此问题的原因似乎是类wxWebControlXmlHandler的构造函数(请参见https://github.com/jonmmorgan/wxwebconnect/blob/master/xh_webcontrol.cpp)未包含在构建的共享库文件中。在xh_webcontrol.o上运行nm显示该符号在该对象文件的文本部分中,并且该对象文件是链接到共享库中的对象文件之一。但是,在共享库文件上运行nm表明它是未定义的,这就是导致崩溃的原因。

我不明白为什么构造函数没有包含在共享库文件中,因为显然是必需的(而且我知道构造函数是在webcontrol.cpp中调用的)。是否有充分的理由呢?有什么我能或应该做的事情,以强制将构造函数包含在共享对象文件中并导出?

用于构建的命令(生成setuptools):
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/gtk/wc_wrap.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/gtk/wc_wrap.o -pthread -O3 -pthread
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/webconnect/dom.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/dom.o -pthread -O3 -pthread
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/webconnect/nsimpl.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/nsimpl.o -pthread -O3 -pthread
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/webconnect/promptservice.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/promptservice.o -pthread -O3 -pthread
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/webconnect/protocolhandler.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/protocolhandler.o -pthread -O3 -pthread
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/webconnect/webcontrol.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/webcontrol.o -pthread -O3 -pthread
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/webconnect/webframe.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/webframe.o -pthread -O3 -pthread
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/webconnect/webprefs.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/webprefs.o -pthread -O3 -pthread
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/webconnect/xh_webcontrol.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/xh_webcontrol.o -pthread -O3 -pthread
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DSWIG_TYPE_TABLE=_wxPython_table -DSWIG_PYTHON_OUTPUT_TUPLE -DWXP_USE_THREAD=1 -UNDEBUG -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -Iinclude -Isrc -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -Icontrib/wc -Icontrib/wc/webconnect -I/usr/include/xulrunner-1.9.2.11 -I/usr/include/python2.6 -c contrib/wc/pyprotocolhandler.cpp -o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/pyprotocolhandler.o -pthread -O3 -pthread
g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/gtk/wc_wrap.o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/dom.o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/nsimpl.o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/promptservice.o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/protocolhandler.o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/webcontrol.o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/webframe.o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/webprefs.o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/webconnect/xh_webcontrol.o build-gtk2.unicode/temp.linux-i686-2.6/contrib/wc/pyprotocolhandler.o -L/usr/X11R6/lib -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8 -lwx_gtk2u_xrc-2.8 -o /home/jmmorgan/wxwebconnect/wxPython-src-2.8.11.0/wxPython/wx/_wc.so -pthread -Wl,-Bsymbolic-functions

最佳答案

尝试将目标文件放在-Wl,--whole-archive -Wl,--no-whole-archive部分中。
man ld:

关于c++ - wxWebConnect的Linux动态链接错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4347000/

10-10 21:25