免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1663 | 回复: 3
打印 上一主题 下一主题

[C] 求教动态链接库问题!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-31 17:31 |只看该作者 |倒序浏览
/mts/usr/hyq/tst>cc -o tt -L/mts/usr/hyq/tst -lhello.so tt.o
ld: 0706-006 Cannot find or open library file: -l hello.so
        ld:open(): A file or directory in the path name does not exist.

/mts/usr/hyq/tst>cc -o tt hello.so tt.o
/mts/usr/hyq/tst>tt
exec(): 0509-036 Cannot load program tt because of the following errors:
        0509-150 Dependent module hello.so could not be loaded.
        0509-022 Cannot load module hello.so.
        0509-026 System error: A file or directory in the path name does not exist.


用下面的方式编译没有问题


/mts/usr/hyq/tst>cc -o tt ./hello.so tt.o

请问一下这三种方式有什么区别吗?

[ 本帖最后由 hyq5436 于 2008-12-31 20:04 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-12-31 20:08 |只看该作者
看来又要贴成坛底了!:wink:
[free][/free]

论坛徽章:
0
3 [报告]
发表于 2008-12-31 20:22 |只看该作者
cc -o tt hello.so tt.o
这是作为普通一个目标文件编译,显然你的hello.so做成的是一个动态库

而你cc -o tt -L/mts/usr/hyq/tst -lhello.so tt.o编译失败的原因是应该把hello.so命名为libhello.so

你还需要注意的是运行时要确认这个库在你所配置的加载路径下。

论坛徽章:
0
4 [报告]
发表于 2008-12-31 20:34 |只看该作者
原帖由 乱.码 于 2008-12-31 20:22 发表
而你cc -o tt -L/mts/usr/hyq/tst -lhello.so tt.o编译失败的原因是应该把hello.so命名为libhello.so
Cannot find or open library file: -l hello.so

上面不就是说明能够认出hello.so库,而不是命名的问题

你还需要注意的是运行时要确认这个库在你所配置的加载路径下

hello.so确实在/mts/usr/hyq/tst目录下

cc -o tt hello.so tt.o
这是作为普通一个目标文件编译,显然你的hello.so做成的是一个动态库


但是,下面为什么可以编译通过?
/mts/usr/hyq/tst>cc -o tt ./hello.so tt.o
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP