LinuxSir.cn,穿越时空的Linuxsir!

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

请问动态库和目标文件的链接问题

[复制链接]
发表于 2005-9-29 13:51:44 | 显示全部楼层 |阅读模式
主要功能实现在1.so中,编译.so时用了-shared -fPIC等参数

main()函数在2.c中,通过dlopen调用1.so(包含了dlfcn.h)

将2.c编译为2.o时,加入了-ldl、-fPIC等参数

链接出错——

g++ 2.0 1.so -o test

报错:
undefined reference to dlopen
undefined reference to test()(1.so中的一个函数)

应该怎么弄啊?
发表于 2005-9-29 16:25:26 | 显示全部楼层
”将2.c编译为2.o时,加入了-ldl“ 不需要吧
最后链接时需要-ldl
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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