Tag Archives: “ undefined reference to ×”

Hi3516DV300 Chip Error: “undefined reference to ×”

When using the Hisilicon hardware interface, I used the MPI library, and then linked this library in the makefile, but an error was reported when compiling the link:

./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'

These signal related functions link pthread library, hi_* The relevant interface goes to the document to check which library it belongs to. Maybe my document doesn’t match the current development board. I haven’t found three consecutive chips, but others must have used such a hot chip, so scheme 1 directly searches the function on the Internet; In scheme 2, I have a header file and library file given by the leader. I can find the corresponding function in the whole header file, and then link in the library file with similar name. As expected, the compilation passed. It should also be noted that the basic library depends on the right. Finally, strncpy_S and other functions. Hisilicon has its own implementation. In the library libsecurec.so (or static library libsecurec. A), this basic library needs to be placed on the right.

Attach your makefile so that you don’t forget it next time

CC       = arm-himix200-linux-gcc
CCFLAGS   = -Wall -O -g

INCLUDE  = -I ./include 
# Name of the executable file
TARGET = encJpeg


# Link library files such as libmpi.a
LIBPATH = -L . /lib/
LIBNAME = -lmpi -live -lupvqe -ldnvqe -lVoiceEngine -lpthread -lsecurec


# regular expression for all .c files in the directory
C_SRCS= $(wildcard . /src/*.c)

# First line dependencies: files that depend after the colon
# Second line rule: $@ for the target file, $^ for all dependent files, $< for the first dependent file
$(TARGET): $(C_SRCS)		
	$(CC) $(CCFLAGS) $(INCLUDE) $(LIBPATH) $(LIBNAME) -o . /build/$@ $^


# make clean removes all .o and target files
clean:
	rm -f ./build/*