我在编译程序时遇到问题,但不知道为什么。我认为这是一个库问题,但我不确定。我在google上搜索过,但没有解决问题。
命令行:
clang `pkg-config --libs opencv ` main.o image_handle.o image_detection.o neural_network.o -o main
这是我的错误消息:
/usr/bin/ld: neural_network.o: undefined reference to symbol 'exp@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [main] Error 1
EDIT: my Makefile
#For the compilation
CC=clang
CPPFLAGS=`pkg-config --cflags opencv`
CFLAGS= -Wall -Wextra -Werror -std=c99 -O2
LDFLAGS=`pkg-config --libs opencv`
SRC= main.c image_handle.c image_detection.c neural_network.c
OBJ= ${SRC:.c=.o}
all: main clean
main: ${OBJ}
clean:
rm -f *~ *.o
#END
最佳答案
/lib/x86_64-linux-gnu/libm.so.6: error adding symbols:
DSO missing from command line
这是链接器告诉你它找到了它正在寻找的符号,但不在你要求它链接的库中。因此,您应该将该库添加到命令行中。 libm
的标志是 -lm
clang main.o image_handle.o image_detection.o neural_network.o \
`pkg-config --libs opencv ` -lm -o main
(您将库放在命令行上需要它们的对象之后。)
关于C 中的编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26565067/