gcc不能链接.so动态链接库 100
编译了一个动态链接库libhello.so文件到/usr/local/lib下,hello主要写了一个inthello_add(inta,intb)配置了/etc/ld....
编译了一个动态链接库libhello.so文件到/usr/local/lib下,hello主要写了一个int hello_add(int a,int b)配置了/etc/ld.so.conf的文件,添加了/usr/local/lib,也ldconfig了,完了编写程序
#include <stdio.h>
int main()
{
int a = 3, b = 4;
printf("%d + %d = %d", a, b, hello_add(a,b));
return 0;
}
编译gcc -o hellotest -lhello hellotest.c
出错,提示
hellotest.c: In function ‘main’:
hellotest.c:10:31: warning: implicit declaration of function ‘hello_add’ [-Wimplicit-function-declaration]
printf("%d + %d = %d",a,b,hello_add(a,b));
^
/tmp/cc6EVqbI.o: In function `main':
hellotest.c:(.text+0x29): undefined reference to `hello_add'
collect2: error: ld returned 1 exit status
求解!!! 展开
#include <stdio.h>
int main()
{
int a = 3, b = 4;
printf("%d + %d = %d", a, b, hello_add(a,b));
return 0;
}
编译gcc -o hellotest -lhello hellotest.c
出错,提示
hellotest.c: In function ‘main’:
hellotest.c:10:31: warning: implicit declaration of function ‘hello_add’ [-Wimplicit-function-declaration]
printf("%d + %d = %d",a,b,hello_add(a,b));
^
/tmp/cc6EVqbI.o: In function `main':
hellotest.c:(.text+0x29): undefined reference to `hello_add'
collect2: error: ld returned 1 exit status
求解!!! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询