2010-12-03 38 views
2

我使用和開發它的wxWebConnect和Python綁定(請參見http://github.com/jonmmorgan/wxwebconnect/http://github.com/jonmmorgan/pywebconnect/)。這些已經建立在Linux之前。然而,當XRC處理器支持加載出錯的.so文件時加入Python程序崩潰:Linux動態鏈接錯誤與wxWebConnect

undefined symbol: _ZN22wxWebControlXmlHandlerC1Ev 

庫已建成並正確地在Mac OS X和Windows上運行以來的變化來做出支持XRC。

此問題的原因似乎是類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 
+0

你能告訴用於連接makefile文件?我找不到一個建築共享庫。 – 2010-12-03 15:51:36

+0

我使用Python setuptools。我會把它使用的命令。 – 2010-12-03 16:01:22

回答

1

嘗試把你的目標文件中-Wl,--whole-archive-Wl,--no-whole-archive部分。

man ld

--whole-archive
For each archive mentioned on the command line after the --whole-archive option, include every object file in the archive in the link, rather than searching the archive for the required object files. This is normally used to turn an archive file into a shared library, forcing every object to be included in the resulting shared library. This option may be used more than once.

Two notes when using this option from gcc: First, gcc doesn't know about this option, so you have to use -Wl,-whole-archive. Second, don't forget to use -Wl,-no-whole-archive after your list of archives, because gcc will add its own list of archives to your link and you may not want this flag to affect those as well.