kongslly 2016-08-17 03:49 采纳率: 0%
浏览 1528

Linux动态库nm可以查询到符号,编译链接时候提示失败

现有一个动态库:
[root@localhost test]# ll /lib64/libplayer.so
-rwxr-xr-x 1 root kongs 19290 8月 16 20:30 /lib64/libplayer.so

使用nm查看如下:
[root@localhost test]# nm /lib64/libplayer.so | grep print_test
00000000000010a0 t print_test

现有测试代码:
int main()
{
printf("playTest\n");
print_test();
return 0;
}

Makefile文件如下:
CC=gcc
CFLAGS=-O3 -Wall -fmessage-length=0 -fPIC -DARCH_x86
OBJS=playerTest.o
LIBS+= -lplayer
TARGET= playerTest
$(TARGET):$(OBJS)
$(CC) -o $(TARGET) $(OBJS) $(CFLAGS) $(LIBS)
chmod 6755 $(TARGET)
all:$(TARGET)
install: all
chmod 6755 $(TARGET)
clean:
rm -f $(OBJS) $(TARGET)

编译提示如下:
[root@localhost test]# make clean
rm -f playerTest.o playerTest
[root@localhost test]# make
gcc -O3 -Wall -fmessage-length=0 -fPIC -DARCH_x86 -c -o playerTest.o playerTest.c
gcc -o playerTest playerTest.o -O3 -Wall -fmessage-length=0 -fPIC -DARCH_x86 -lplayer -lcua
playerTest.o: In function main':
playerTest.c:(.text+0x13): undefined reference to
print_test'
collect2: ld 返回 1
make: *** [playerTest] 错误 1
[root@localhost test]#

这是什么原因?很奇怪

  • 写回答

1条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!