无法使用 TclPro1.4 创建自定义 TCL 解释器:未定义对“__ctype_b”的引用;
我正在尝试根据 TclPro 用户指南 第 7 章,但失败并出现链接错误 对 __ctype_b 的未定义引用
。
我已经在 /opt/ajuba/TclPro1.4/
下载并安装了 TclPro 1.4,这是我想要构建的自定义解释器:
// file simple.cpp
#include <proWrap.h>
int main( int argc, char** argv )
{
Pro_WrapTclMain( argc, argv, &Tcl_Init );
return 0;
}
所以它除了调用 Pro_WrapTclMain
之外什么也不做与标准的Tcl_Init
。
我正在尝试使用此命令构建 simple.cpp
:
g++ -DNDEBUG -O3 -fpic -Wall -pedantic -I/opt/ajuba/TclPro1.4/include simple.cpp -static -Wl,-R/opt/ajuba/TclPro1.4/linux-ix86/lib -L/opt/ajuba/TclPro1.4/linux-ix86/lib -lwrapper1.4 -ltcl8.3 -o out
这是我收到的第一条错误消息(您可以在底部找到完整日志):
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o): In function `envargs':
envargs.c:(.text+0x1e): undefined reference to `__ctype_b'
似乎 __ctype_b
是TclPro 期望在 libc.a 中定义的符号,但
nm /usr/lib/libc.a | grep __ctype_b
给出的
00000080 T __ctype_b_loc
结果是在 libc.a 中没有定义 __ctype_b。
问题是:在这种情况下如何使用 TclPro 构建自定义 TCL 解释器?
如果__ctype_b
应该定义在libc.a
,那么我怎样才能获得合适的libc.a
?
这是编译的完整日志:
g++ -DNDEBUG -O3 -fpic -Wall -pedantic -I/opt/ajuba/TclPro1.4/include simple.cpp -static -Wl,-R/opt/ajuba/TclPro1.4/linux-ix86/lib -L/opt/ajuba/TclPro1.4/linux-ix86/lib -lwrapper1.4 -ltcl8.3 -o out
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixPipe.o): In function `TclpCreateTempFile':
tclUnixPipe.c:(.text+0xe0): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `GetGroupAttribute':
tclUnixFCmd.c:(.text+0xb5b): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `SetGroupAttribute':
tclUnixFCmd.c:(.text+0xd59): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `GetGroupAttribute':
tclUnixFCmd.c:(.text+0xba1): warning: Using 'endgrent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `SetOwnerAttribute':
tclUnixFCmd.c:(.text+0xe7d): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `GetOwnerAttribute':
tclUnixFCmd.c:(.text+0xc14): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
tclUnixFCmd.c:(.text+0xc5e): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixChan.o): In function `TcpGetOptionProc':
tclUnixChan.c:(.text+0x8de): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixChan.o): In function `CreateSocketAddress':
tclUnixChan.c:(.text+0xe4c): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclIOSock.o): In function `TclSockGetPort':
tclIOSock.c:(.text+0x47): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o): In function `envargs':
envargs.c:(.text+0x1e): undefined reference to `__ctype_b'
envargs.c:(.text+0x5d): undefined reference to `__ctype_b'
envargs.c:(.text+0x193): undefined reference to `__ctype_b'
envargs.c:(.text+0x1c0): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o): In function `count_args':
envargs.c:(.text+0x23d): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o):envargs.c:(.text+0x29b): more undefined references to `__ctype_b' follow
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(fileio.o): In function `UzpMorePause':
fileio.c:(.text+0x9a8): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(fileio.o): In function `do_string':
fileio.c:(.text+0xf31): undefined reference to `__ctype_b'
fileio.c:(.text+0xf4a): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(fileio.o): In function `zstrnicmp':
fileio.c:(.text+0x120c): undefined reference to `__ctype_b'
fileio.c:(.text+0x1215): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(match.o): In function `recmatch':
match.c:(.text+0x127): undefined reference to `__ctype_tolower'
match.c:(.text+0x15f): undefined reference to `__ctype_b'
match.c:(.text+0x1ad): undefined reference to `__ctype_b'
match.c:(.text+0x24b): undefined reference to `__ctype_b'
match.c:(.text+0x264): undefined reference to `__ctype_tolower'
match.c:(.text+0x28d): undefined reference to `__ctype_b'
match.c:(.text+0x2a6): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(unix.o): In function `mapname':
unix.c:(.text+0x441): undefined reference to `__ctype_b'
unix.c:(.text+0x47b): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclIOUtil.o): In function `TclGetOpenMode':
tclIOUtil.c:(.text+0x36): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclListObj.o): In function `SetListFromAny':
tclListObj.c:(.text+0x7e6): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclLoad.o): In function `Tcl_LoadObjCmd':
tclLoad.c:(.text+0x3cc): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclObj.o):tclObj.c:(.text+0x7e8): more undefined references to `__ctype_b' follow
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclLoadDl.o): In function `TclpLoadFile':
tclLoadDl.c:(.text+0x35): undefined reference to `dlopen'
tclLoadDl.c:(.text+0x5a): undefined reference to `dlerror'
tclLoadDl.c:(.text+0xa1): undefined reference to `dlsym'
tclLoadDl.c:(.text+0xe0): undefined reference to `dlsym'
tclLoadDl.c:(.text+0x119): undefined reference to `dlsym'
tclLoadDl.c:(.text+0x158): undefined reference to `dlsym'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclLoadDl.o): In function `TclpUnloadFile':
tclLoadDl.c:(.text+0x19c): undefined reference to `dlclose'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclBinary.o): In function `Tcl_BinaryObjCmd':
tclBinary.c:(.text+0xbe4): undefined reference to `__ctype_b'
tclBinary.c:(.text+0xc5d): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclBinary.o): In function `GetFormatSpec':
tclBinary.c:(.text+0x1617): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclCmdAH.o): In function `Tcl_CaseObjCmd':
tclCmdAH.c:(.text+0x185): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclCmdAH.o): In function `Tcl_FormatObjCmd':
tclCmdAH.c:(.text+0x22f5): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclCmdAH.o):tclCmdAH.c:(.text+0x23f8): more undefined references to `__ctype_b' follow
collect2: ld returned 1 exit status
make: *** [out] Error 1
I am trying to create a custom TCL interpreter with TclPro according instructions at TclPro User's Guide Chapter 7, but it fails with linking error undefined reference to __ctype_b
.
I have downloaded and installed TclPro 1.4 at /opt/ajuba/TclPro1.4/
, and here is the custom interpreter I want to build:
// file simple.cpp
#include <proWrap.h>
int main( int argc, char** argv )
{
Pro_WrapTclMain( argc, argv, &Tcl_Init );
return 0;
}
So it does nothing but calls Pro_WrapTclMain
with standard Tcl_Init
.
I am trying to build simple.cpp
with this command:
g++ -DNDEBUG -O3 -fpic -Wall -pedantic -I/opt/ajuba/TclPro1.4/include simple.cpp -static -Wl,-R/opt/ajuba/TclPro1.4/linux-ix86/lib -L/opt/ajuba/TclPro1.4/linux-ix86/lib -lwrapper1.4 -ltcl8.3 -o out
and here is the first error message I get (you can find the full log at the bottom):
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o): In function `envargs':
envargs.c:(.text+0x1e): undefined reference to `__ctype_b'
Seems __ctype_b
is a symbol which TclPro expects to be defined at libc.a, but
nm /usr/lib/libc.a | grep __ctype_b
gives
00000080 T __ctype_b_loc
so there is no __ctype_b defined at libc.a.
The question is: how to build a custom TCL interpreter with TclPro in this situation?
If __ctype_b
should be defined at libc.a
, then how can I obtain an appropriate libc.a
?
Here is the full log of compilation:
g++ -DNDEBUG -O3 -fpic -Wall -pedantic -I/opt/ajuba/TclPro1.4/include simple.cpp -static -Wl,-R/opt/ajuba/TclPro1.4/linux-ix86/lib -L/opt/ajuba/TclPro1.4/linux-ix86/lib -lwrapper1.4 -ltcl8.3 -o out
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixPipe.o): In function `TclpCreateTempFile':
tclUnixPipe.c:(.text+0xe0): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `GetGroupAttribute':
tclUnixFCmd.c:(.text+0xb5b): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `SetGroupAttribute':
tclUnixFCmd.c:(.text+0xd59): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `GetGroupAttribute':
tclUnixFCmd.c:(.text+0xba1): warning: Using 'endgrent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `SetOwnerAttribute':
tclUnixFCmd.c:(.text+0xe7d): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `GetOwnerAttribute':
tclUnixFCmd.c:(.text+0xc14): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
tclUnixFCmd.c:(.text+0xc5e): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixChan.o): In function `TcpGetOptionProc':
tclUnixChan.c:(.text+0x8de): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixChan.o): In function `CreateSocketAddress':
tclUnixChan.c:(.text+0xe4c): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclIOSock.o): In function `TclSockGetPort':
tclIOSock.c:(.text+0x47): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o): In function `envargs':
envargs.c:(.text+0x1e): undefined reference to `__ctype_b'
envargs.c:(.text+0x5d): undefined reference to `__ctype_b'
envargs.c:(.text+0x193): undefined reference to `__ctype_b'
envargs.c:(.text+0x1c0): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o): In function `count_args':
envargs.c:(.text+0x23d): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o):envargs.c:(.text+0x29b): more undefined references to `__ctype_b' follow
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(fileio.o): In function `UzpMorePause':
fileio.c:(.text+0x9a8): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(fileio.o): In function `do_string':
fileio.c:(.text+0xf31): undefined reference to `__ctype_b'
fileio.c:(.text+0xf4a): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(fileio.o): In function `zstrnicmp':
fileio.c:(.text+0x120c): undefined reference to `__ctype_b'
fileio.c:(.text+0x1215): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(match.o): In function `recmatch':
match.c:(.text+0x127): undefined reference to `__ctype_tolower'
match.c:(.text+0x15f): undefined reference to `__ctype_b'
match.c:(.text+0x1ad): undefined reference to `__ctype_b'
match.c:(.text+0x24b): undefined reference to `__ctype_b'
match.c:(.text+0x264): undefined reference to `__ctype_tolower'
match.c:(.text+0x28d): undefined reference to `__ctype_b'
match.c:(.text+0x2a6): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(unix.o): In function `mapname':
unix.c:(.text+0x441): undefined reference to `__ctype_b'
unix.c:(.text+0x47b): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclIOUtil.o): In function `TclGetOpenMode':
tclIOUtil.c:(.text+0x36): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclListObj.o): In function `SetListFromAny':
tclListObj.c:(.text+0x7e6): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclLoad.o): In function `Tcl_LoadObjCmd':
tclLoad.c:(.text+0x3cc): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclObj.o):tclObj.c:(.text+0x7e8): more undefined references to `__ctype_b' follow
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclLoadDl.o): In function `TclpLoadFile':
tclLoadDl.c:(.text+0x35): undefined reference to `dlopen'
tclLoadDl.c:(.text+0x5a): undefined reference to `dlerror'
tclLoadDl.c:(.text+0xa1): undefined reference to `dlsym'
tclLoadDl.c:(.text+0xe0): undefined reference to `dlsym'
tclLoadDl.c:(.text+0x119): undefined reference to `dlsym'
tclLoadDl.c:(.text+0x158): undefined reference to `dlsym'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclLoadDl.o): In function `TclpUnloadFile':
tclLoadDl.c:(.text+0x19c): undefined reference to `dlclose'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclBinary.o): In function `Tcl_BinaryObjCmd':
tclBinary.c:(.text+0xbe4): undefined reference to `__ctype_b'
tclBinary.c:(.text+0xc5d): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclBinary.o): In function `GetFormatSpec':
tclBinary.c:(.text+0x1617): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclCmdAH.o): In function `Tcl_CaseObjCmd':
tclCmdAH.c:(.text+0x185): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclCmdAH.o): In function `Tcl_FormatObjCmd':
tclCmdAH.c:(.text+0x22f5): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclCmdAH.o):tclCmdAH.c:(.text+0x23f8): more undefined references to `__ctype_b' follow
collect2: ld returned 1 exit status
make: *** [out] Error 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您的平台的详细信息是什么,但是 这条消息似乎包含了答案。本质上,您将此代码添加到
simple.cpp
并重新编译:您显然还需要将此选项添加到链接行:
-Wl,--wrap,__ctype_b
希望这个帮助...
I don't know for sure what the details of your platform are, but this message would seem to hold the answer. In essence, you add this code to
simple.cpp
and recompile:You also apparently need to this option to the linking line:
-Wl,--wrap,__ctype_b
Hope this helps...