undefined symbol 问题解决记录(一)

历经一个月,昨日完成打印机network部分的编写(c语言),编写makefile构建动态库。构建完成后遂进行调用测试,出现:./network: symbol lookup error: /usr/lib64/netPrnctl.so: undefined symbol: cupsGetDests将解决方法与过程记录,以便日后查阅。查找与分析原因在编译时未出现问题,没有报错,成功编译生成动态库。以下为编译的makefile文件。#################################
摘要由CSDN通过智能技术生成

历经一个月,昨日完成打印机network部分的编写(c语言),编写makefile构建动态库。构建完成后遂进行调用测试,出现:

./network: symbol lookup error: /usr/lib64/netPrnctl.so: undefined symbol: cupsGetDests

将解决方法与过程记录,以便日后查阅。

查找与分析原因

在编译时未出现问题,没有报错,成功编译生成动态库。以下为编译的makefile文件。

###########################################################
#	File:	netPrnctl.so Makefile
#	Author: Neko
###########################################################

CC = gcc
CFLAGS = -Wall -g -fPIC

INCLUDE = -I./inc -I../ -I../cups -I../backend -I/usr/include/libusb-1.0
TARGET = netPrnctl.so

vpath % .h ./inc

OBJS	= public.o prnctlAvision.o prnctlNetwork.o prnctl.o
SRCS	= ./src/public.c ./src/prnctlAvision.c ./src/prnctlNetwork.c ./src/prnctl.c

$(OBJS):$(SRCS)
	$(CC) $(CFLAGS) $(INCLUDE) -c $^

all:$(OBJS)
	$(CC) -shared -fPIC -o $(TARGET) $(OBJS) -pthread
	cp $(TARGET) /usr/bin
	cp $(TARGET) /usr/lib64

clean:
	rm -f *.o
	rm -f netPrnctl.so

虽成功生成了动态库,但是在调用时却出现找不到符号的问题,于是使用 ldd -r 查看

neko@neko:~/ZCPrinterDevice/NetworkSetupTool/filter$ ldd -r /usr/lib64/netPrnctl.so
	linux-vdso.so.1 (0x00007ffeef44c000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9607add000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f96076ec000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f9607f0f000)
undefined symbol: libusb_open	(/usr/lib64/netPrnctl.so)
undefined symbol: cupsArrayNew	(/usr/lib64/netPrnctl.so)
undefined symbol: cupsDirOpen	(/usr/lib64/netPrnctl.so)
undefined symbol: ppdFindAttr	(/usr/lib64/netPrnctl.so)
undefined symbol: cupsParseOptions	(/usr/lib64/netPrnctl.so)
undefined symbol: cupsGetPPD	(/usr/lib64/netPrnctl.so)
undefined symbol: libusb_set_interface_alt_setting	(/usr/lib64/netPrnctl.so)
undefined symbol: libusb_release_interface	(/usr/lib64/netPrnctl.so)
undefined symbol: ppdClose	(/usr/lib64/netPrnctl.so)
undefined symbol: cupsGetOption	(/usr/lib64/netPrnctl.so)
undefined symbol: libusb_detach_kernel_driver	(/usr/lib64/netPrnctl.so)
undefined symbol: libusb_close	(/usr/lib64/netPrnctl.so)
undefined symbol: cupsFreeOptions	(/usr/lib64/netPrnc
  • 13
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值