现有一个动态库:
[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':
print_test'
playerTest.c:(.text+0x13): undefined reference to
collect2: ld 返回 1
make: *** [playerTest] 错误 1
[root@localhost test]#
这是什么原因?很奇怪