Hi3516DV300芯片报错“ undefined reference to ×”

我在使用海思硬件接口的时候,用到了mpi库,然后Makefile里面链接了这个库,但是编译到了链接的时候报错了:


./lib//libmpi.so: undefined reference to `sem_post'
./lib//libmpi.so: undefined reference to `snprintf_s'
./lib//libmpi.so: undefined reference to `sincos'
./lib//libmpi.so: undefined reference to `HI_DNVQE_ReadFrame'
./lib//libmpi.so: undefined reference to `HI_VOICE_EncodeFrame'
./lib//libmpi.so: undefined reference to `atan2'
./lib//libmpi.so: undefined reference to `HI_UPVQE_Create'
./lib//libmpi.so: undefined reference to `HI_UPVQE_SetVolume'
./lib//libmpi.so: undefined reference to `sem_trywait'
./lib//libmpi.so: undefined reference to `acos'
./lib//libmpi.so: undefined reference to `HI_UPVQE_GetVolume'
./lib//libmpi.so: undefined reference to `HI_VOICE_DecReset'
./lib//libmpi.so: undefined reference to `HI_DNVQE_WriteFrame'
./lib//libmpi.so: undefined reference to `HI_DNVQE_Create'
./lib//libmpi.so: undefined reference to `sin'
./lib//libmpi.so: undefined reference to `HI_UPVQE_Destroy'
./lib//libmpi.so: undefined reference to `HI_UPVQE_GetConfig'
./lib//libmpi.so: undefined reference to `sem_getvalue'
./lib//libmpi.so: undefined reference to `sem_wait'
./lib//libmpi.so: undefined reference to `HI_VOICE_EncReset'
./lib//libmpi.so: undefined reference to `sem_init'
./lib//libmpi.so: undefined reference to `HI_UPVQE_ReadFrame'
./lib//libmpi.so: undefined reference to `memcpy_s'
./lib//libmpi.so: undefined reference to `tan'
./lib//libmpi.so: undefined reference to `HI_UPVQE_WriteFrame'
./lib//libmpi.so: undefined reference to `memmove_s'
./lib//libmpi.so: undefined reference to `pthread_join'
./lib//libmpi.so: undefined reference to `HI_VOICE_DecodeFrame'
./lib//libmpi.so: undefined reference to `pthread_create'
./lib//libmpi.so: undefined reference to `pow'
./lib//libmpi.so: undefined reference to `round'
./lib//libmpi.so: undefined reference to `log10'
./lib//libmpi.so: undefined reference to `HI_DNVQE_GetConfig'
./lib//libmpi.so: undefined reference to `sqrt'
./lib//libmpi.so: undefined reference to `sem_destroy'
./lib//libmpi.so: undefined reference to `memset_s'
./lib//libmpi.so: undefined reference to `strncpy_s'
./lib//libmpi.so: undefined reference to `HI_DNVQE_Destroy'

这些信号相关的函数链接pthread库,HI_*相关的接口去文档查属于哪个库,或许我的文档跟当前开发板不匹配,我连续找了三个没找到,不过这么火的芯片别人肯定也用过,所以方案一直接上网搜该函数;方案二我有一份领导给的头文件和库文件,我到整个头文件里面能找到相应的函数,然后就去把名字差不多的库文件链接进去,果然编译通过了。还有要特别注意的是基础库要靠右侧。最后,strncpy_s等几个函数海思有自己的实现,在库libsecurec.so(或静态库libsecurec.a)里面,这个基础库要靠右侧放。

附上自己的Makefile吧,省得下次忘记了

CC      := arm-himix200-linux-gcc
CCFLAGS  := -Wall -O -g
 
INCLUDE  := -I ./include 
# 可执行文件的名字
TARGET  := encJpeg 
 
# 链接 libmpi.a等库文件
LIBPATH  = -L ./lib/
LIBNAME   =  -lmpi -live -lupvqe -ldnvqe  -lVoiceEngine -lpthread  -lsecurec
 
 
#正则表达式表示目录下所有.c文件,
C_SRCS= $(wildcard ./src/*.c)
 
# 第一行依赖关系:冒号后面为依赖的文件
# 第二行规则:$@表示目标文件,$^表示所有依赖文件,$<表示第一个依赖文件
$(TARGET): $(C_SRCS)        
    $(CC)   $(CCFLAGS) $(INCLUDE)  $(LIBPATH) $(LIBNAME)  -o ./build/$@  $^
 
 
# make clean删除所有.o和目标文件
clean:
    rm -f ./build/* 
posted @ 2021-10-27 11:12  时间的风景  阅读(772)  评论(0编辑  收藏  举报