编译动态连接库的问题

小魔菇 小魔菇 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
test.c

#include <stdio.h>
void print()
{
printf("------------------------\n");
}

gcc -c test.c
gcc -shared -o libtest.so test.o
生成了libtest.so库
然后我调用它
main.c

extern void print();
int main()
{
print();
return 0;
}

gcc -L./ -ltest -o main main.c
./main
error while loading shared libraries: libtest.so: cannot open shared object file: No such file or directory

请高手指点一下 不知道哪儿错了
...全文
评论 10
收藏 已收藏
分享
返回顶部
小魔菇
Linux/Unix社区 23,224 成员 74,535 内容