问题简单的Makefile:未定义的参考符号“COS @@ GLIBC_2.2.5” [英] Issue with simple Makefile: undefined reference to symbol 'cos@@GLIBC_2.2.5'
本文介绍了问题简单的Makefile:未定义的参考符号“COS @@ GLIBC_2.2.5”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图编译使用一个Makefile一些测试C $ C $℃。
在的main.c
文件包括两个头:
I'm trying to compìle some test C code using a Makefile.
The main.c
file includes two headers:
#include "circle_buffer.h"
#include "window.h"
和当我执行下面的Makefile
and when I execute the following Makefile
# compiler
CC=gcc
# compiler flags:
# -g adds debugging information to the executable file
# -Wall turns on most, but not all, compiler warnings
CFLAGS=
# include path
INCLUDES =
# library path and names
LIBS=-L/usr/lib/x86_64-linux-gnu -lsndfile
MAIN = test
$(MAIN): main.o circle_buffer.o window.o
$(CC) main.o circle_buffer.o window.o -o $(MAIN) $(LIBS)
main.o: main.c circle_buffer.h window.h
$(CC) -c main.c $(INCLUDES)
circle_buffer.o: circle_buffer.c circle_buffer.h
$(CC) -c circle_buffer.c $(INCLUDES)
window.o: window.h
$(CC) -c window.c $(INCLUDES)
.PHONY: clean
clean:
rm -rf *o $(MAIN)
我得到
xxx@xxx:~/source$ make
gcc -c main.c
gcc -c circle_buffer.c
gcc -c window.c
gcc main.o circle_buffer.o window.o -o test -L/usr/lib/x86_64-linux-gnu -lsndfile
/usr/bin/ld: window.o: undefined reference to symbol 'cos@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [test] Error 1
如果我删除的#includewindow.h中
从的main.c
,以及窗口中的所有引用在Makefile的.o / H / C,它的工作原理。
If I remove #include "window.h"
from main.c
, and all the references to window.o/h/c in the Makefile, it works.
我在想什么?我在哪里打破了规则
What am I missing? Where am I breaking the rule
target: dependencies
[tab] system command
推荐答案
听起来像数学库,的libm
需要被链接。添加 -lm
来的联阶段。
Sounds like the math library, libm
needs to be linked in. Add -lm
to the linking stage.
LIBS=-L/usr/lib/x86_64-linux-gnu -lsndfile -lm
这篇关于问题简单的Makefile:未定义的参考符号“COS @@ GLIBC_2.2.5”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文