1

我在构建图书馆时遇到问题。在 Makefile 中,我通过输入 -ltclstub8.6 告诉 g++ 我需要 tclstub8.6 并且 g++ 将其考虑在内(抱歉这些法语消息):

make: AVERTISSEMENT : le fichier « ../Linux-PORT/i586-GCC4/Makefile » a une date de modification 609 s dans le futur
*** Compile c [gcc] libtestGuiMnt_info.Linux-PORT.i586-GCC4.c
*** Compile C++ [g++] mntdisplay.cc
*** Compile C++ [g++] mntogl.cc
mntogl.cc: In member function 'virtual int MNTOgl::Display() const':
mntogl.cc:228:12: warning: unused variable 'ErrorCheckValue' [-Wunused-variable]
*** Compile C++ [g++] mntdisplaylist.cc
*** Compile C++ [g++] mntmanager.cc
*** Compile C++ [g++] mntdisplay_wrap.cc
*** Link (g++) librairie partagée /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1 -Wl,-Bdynamic -L/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib -Wl,-rpath,/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib -lapcomutil -lapmntcom -lapmntdata -lapmntnoyau -lapcomenvEtude -lapcomenv -ltclstub8.6 -lGLEW -lGLU -lGL -lglut
make: AVERTISSEMENT : décalage d'horloge détecté. La construction peut être incomplète.

但是当我调用一个 tcl 函数时,会发生段错误。

事实上,如果我检查我刚刚使用 ldd -r 命令构建的库,它会显示所有外部库都包含在内,除了 tclstub8.6。

下面是 ldd -r 命令的输出信息。注意libtclstub8.6没有出现..

该列表以 libtclstub8.6 的所有未定义符号结束。

ldd -r /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1
        linux-gate.so.1 (0xb777e000)
        libapcomutil.2 => /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libapcomutil.2 (0xb7743000)
        libapmntcom.1 => /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libapmntcom.1 (0xb773f000)
        libapmntdata.3 => /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libapmntdata.3 (0xb770f000)
        libapmntnoyau.4 => /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libapmntnoyau.4 (0xb76e9000)
        libapcomenvEtude.1 => /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libapcomenvEtude.1 (0xb76cc000)
        libapcomenv.1 => /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libapcomenv.1 (0xb76b8000)
        libGLEW.so.1.9 => /usr/lib/libGLEW.so.1.9 (0xb762e000)
        libGLU.so.1 => /usr/lib/libGLU.so.1 (0xb75a6000)
        libGL.so.1 => /usr/lib/libGL.so.1 (0xb7546000)
        libglut.so.3 => /usr/lib/libglut.so.3 (0xb750a000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb741e000)
        libm.so.6 => /lib/libm.so.6 (0xb73dc000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb73be000)
        libc.so.6 => /lib/libc.so.6 (0xb7244000)
        libapcomfichier.3 => /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libapcomfichier.3 (0xb7235000)
        libapcomitineraire.3 => /apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libapcomitineraire.3 (0xb7190000)
        libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb7036000)
        libz.so.1 => /lib/libz.so.1 (0xb701f000)
        libgfortran.so.3 => /usr/lib/libgfortran.so.3 (0xb6f22000)
        libglapi.so.0 => /usr/lib/libglapi.so.0 (0xb6f0c000)
        libXext.so.6 => /usr/lib/libXext.so.6 (0xb6ef9000)
        libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0xb6ef5000)
        libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0xb6eef000)
        libX11-xcb.so.1 => /usr/lib/libX11-xcb.so.1 (0xb6eeb000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0xb6db1000)
        libxcb-glx.so.0 => /usr/lib/libxcb-glx.so.0 (0xb6d98000)
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb6d75000)
        libXxf86vm.so.1 => /usr/lib/libXxf86vm.so.1 (0xb6d6f000)
        libdrm.so.2 => /usr/lib/libdrm.so.2 (0xb6d61000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb6d45000)
        libdl.so.2 => /lib/libdl.so.2 (0xb6d40000)
        libXi.so.6 => /usr/lib/libXi.so.6 (0xb6d30000)
        libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0xb6d25000)
        /lib/ld-linux.so.2 (0xb777f000)
        liblzma.so.5 => /usr/lib/liblzma.so.5 (0xb6cfb000)
        libquadmath.so.0 => /usr/lib/libquadmath.so.0 (0xb6c82000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0xb6c7e000)
        libXrender.so.1 => /usr/lib/libXrender.so.1 (0xb6c73000)
undefined symbol: Tcl_DeleteCommandFromToken    (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_NewStringObj      (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_GetCommandInfo    (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_SetObjResult      (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_GetLongFromObj    (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_InitHashTable     (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_CreateObjCommand  (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_NewBooleanObj     (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_SetResult (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_GetStringResult   (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_SetVar    (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_VarEval   (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_GetVar    (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_AppendResult      (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_AppendElement     (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_ObjSetVar2        (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_ResetResult       (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_SetErrorCode      (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_PkgProvide        (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: _ZN10MNTManager10DisplayAllEv (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_GetStringFromObj  (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_NewDoubleObj      (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_GetBooleanFromObj (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_GetObjResult      (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: TclFreeObj    (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_GetDoubleFromObj  (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_DuplicateObj      (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_DeleteHashEntry   (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)
undefined symbol: Tcl_NewIntObj (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)

有人可以帮我解决这个问题吗?非常感谢!

4

1 回答 1

1

我找到了。

事实上,一切都是因为这条线:

undefined symbol: _ZN10MNTManager10DisplayAllEv (/apollo/Developpement/Build-GCC4/Obj/Linux-PORT/i586-GCC4/lib/libtestGuiMnt.1)

MY library有一个未定义的符号。我定义了它并解决了问题!

请看我的原帖: segfault using SWIG convert code for tcl

令人困惑的是,我的程序在 tcl 包装函数的中间崩溃了(我的未定义符号根本不涉及)。我真的不知道为什么,但就是这样。。

希望它会帮助别人!

于 2013-08-22T12:19:19.240 回答