LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 879|回复: 6

ct_lib问题

[复制链接]
发表于 2003-10-24 17:48:28 | 显示全部楼层 |阅读模式
兄弟用ct_lib写一个客户端程序,编译出现

/tmp/ccRjjFeO.o(.text+0x5c): undefined reference to `ct_exit'
/tmp/ccRjjFeO.o(.text+0x6a): undefined reference to `cs_ctx_drop'
/tmp/ccRjjFeO.o(.text+0x85): undefined reference to `ct_init'
/tmp/ccRjjFeO.o(.text+0xc7): undefined reference to `ct_exit'
/tmp/ccRjjFeO.o(.text+0xd5): undefined reference to `cs_ctx_drop'
/tmp/ccRjjFeO.o(.text+0x102): undefined reference to `cs_config'
/tmp/ccRjjFeO.o(.text+0x144): undefined reference to `ct_exit'
/tmp/ccRjjFeO.o(.text+0x152): undefined reference to `cs_ctx_drop'
/tmp/ccRjjFeO.o(.text+0x176): undefined reference to `ct_callback'
/tmp/ccRjjFeO.o(.text+0x1b8): undefined reference to `ct_exit'
……
等问题,不知道是头文件没有包括还是没有找到相应的库。编译选项
# gcc -o ctlib ctlib.c -I /usr/local/freetds/include -L /usr/local/freetds/lib
发表于 2003-10-24 18:07:34 | 显示全部楼层
没有连接库文件,-L 是指明非默认的库的路径,-l 才是连接库
 楼主| 发表于 2003-10-25 11:29:03 | 显示全部楼层
因为是需要很多的库文件了,所有就指定了库文件的路径,不知道可不可以
发表于 2003-10-25 11:54:14 | 显示全部楼层
不行,指定库的路径和指定库不是一回事,除了默认连接的库,其它库必需指定连接,比如 -lncurses,这里ncurses在/usr/lib下,这是默认的库路径,所以不需要指定库路径,如果库不在/usr/lib这种默认的库路径下就必需指定路径,象你的程序必需同时指定库和库路径
 楼主| 发表于 2003-10-25 12:11:21 | 显示全部楼层
我的库的路径是 /usr/local/freetds/lib/
我先,ehco /usr/local/freetds/lib >>/etc/ld.so.conf
然后,ldconfig 显示
ldconfig: /lib/libnasl.so.2 is not a symbolic link
这样应该是把动态链接库加到默认的路径了吧。
同时我用nm *.* |grep ct_* 找到了所需的函数确实在库中。
# gcc -o ctlib ctlib.c -I/usr/local/freetds/include \
-l /usr/local/freetds/lib/libct.so.1 \
-l /usr/local/freetds/lib/libsybdb.so.3.0
显示/usr/bin/ld: cannot find
-l/usr/local/freetds/lib/libct.so.1
collect2: ld returned 1 exit status
加上 -L/usr/local/freetds/lib 回显同上。
路径没有问题
奇怪!
发表于 2003-10-25 12:34:26 | 显示全部楼层
你用:
gcc -o ctlib ctlib.c -I/usr/local/freetds/include -lct -lsybdb
试试
 楼主| 发表于 2003-10-28 09:05:01 | 显示全部楼层
谢谢老兄,我用gcc -o ctlib ctlib.c -I/usr/local/freetds/include -L/usr/local/freetds/lib -lct -lsybdb
编译选项成功编译了,再次表示感谢!

这贴有些灌水的嫌疑了,可是不感谢又心里不安!呵呵……
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表