我在 Linux (Ubuntu 13.10) 中使用 OpenGL 开始一个项目,我有一个来自教授的基本源代码,可以在他的计算机上编译。
当我试图在这里编译它时,(我有在其他项目中工作的 open gl 库),我在终端中收到以下错误:
gcc -o quadtree quadtree.o glm.o winGL.o -lglut -lGL -lGLU
/usr/bin/ld: glm.o: referência indefinida ao símbolo 'acos@@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: ** [quadtree] Erro 1
(“referência indefinida ao simbolo”的意思是“ undefined symbol 引用”)
我在互联网上搜索并得到提示,这可能是 makefile 中的一个错误,但我不知道哪里出了问题。这是我的生成文件:
.c.o: $*.h
gcc -c $*.c
.cpp.o: $*.h
g++ -c $*.cpp
all: quadtree
quadtree: quadtree.o glm.o winGL.o
gcc -o $@ $^ -lglut -lGL -lGLU
clean:
rm *.o *.*~ *~ quadtree
是否缺少任何命令?
最佳答案
你忘了用-lm
链接,见man acos
关于Ubuntu 13.10 中的 C 编译错误,可能是 makefile 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21367160/