I have the following error:
(我有以下错误:)
/usr/bin/ld: pixel_operations.o: in function `update_surface':
pixel_operations.c:(.text+0xf7): undefined reference to `SDL_UpperBlit'
/usr/bin/ld: pixel_operations.c:(.text+0x121): undefined reference to `SDL_GetError'
/usr/bin/ld: pixel_operations.c:(.text+0x114): undefined reference to `SDL_UpdateRect'
I have the following Makefile:
(我有以下Makefile:)
CFLAGS= -Wall -Wextra -Werror -std=c99 -O3
CPPFLAGS=`pkg-config --cflags sdl` -MMD
LDFLAGS=
LDLIBS= `pkg-config --libs sdl` -lSDL_image
EXEC= main
SRC= matrix.o random.o pixel_operations.o layer.c train.c neural_net.c main.c save_net.c
all: net
net: ${SRC}
gcc ${CPPFLAGS} ${CFLAGS} -o ${EXEC} ${SRC} -lm
matrix.o: ../Misc/matrix.c
gcc ${CFLAGS} -o matrix.o -c ../Misc/matrix.c
random.o: ../Misc/random.c
gcc ${CFLAGS} -o random.o -c ../Misc/random.c
otsu.o: ../Binarize/otsu.c
gcc ${CFLAGS} -o otsu.o -c ../Binarize/otsu.c
pixel_operations.o: ../Binarize/pixel_operations.c
gcc ${CFLAGS} ${CPPFLAGS} -o pixel_operations.o -c ../Binarize/pixel_operations.c ${LDLIBS}
clean:
rm -f *.o
rm -f ../Misc/*.d
rm -f *.txt
rm ${EXEC}
I don't understand why SDL is not referenced as I used pkg-config.
(我不明白为什么在使用pkg-config时未引用SDL。)
SDL is used in pixel_operation.c and otsu.c. (SDL用于pixel_operation.c和otsu.c。)
Some of the research I made said that the libs must be at the end of the compile command but in my case, regardless of where I put it it doesn't work. (我做过的一些研究说,库必须在编译命令的末尾,但是就我而言,无论我放在哪里,它都行不通。)
How can I fix this ? (我怎样才能解决这个问题 ?)
ask by Firox translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…