未定义引用符号'gluLookAt'[复制]

时间:2021-05-26 05:29:03

This question already has an answer here:

这个问题已经有了答案:

I'm using Fedora 16. I've installed freeglut and freeglut-devel packages. I tried to rum a simple opengl program, but i'm getting the following error

我使用Fedora 16。我已经安装了freeglut和freeglut-devel包。我尝试使用一个简单的opengl程序,但是我得到了以下错误。

gcc cube.c -o cube -lglut
/usr/bin/ld: /tmp/ccSFol4w.o: undefined reference to symbol 'gluLookAt'
/usr/bin/ld: note: 'gluLookAt' is defined in DSO /usr/lib/libGLU.so.1 so try adding it to the linker command line
/usr/lib/libGLU.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

5 个解决方案

#1


2  

You have to link some gl libraries.

你必须连接一些gl库。

g++ cube.c -o cube -I /usr/lib/libglut.so.3 /usr/lib/libGL.so.1 /usr/lib/libGLU.so.1 -lGL

#2


6  

Compile : g++ sampleCode.cpp -lglut -lGL -lGLU

编译:g++ sampleCode。cpp -lglut -lGL -lGLU

run : ./a.out

运行:. / a.o ut

is your answer.

是你的答案。

#3


2  

do what it says

做什么它说

gcc cube.c -o cube -lglut -lGLU

#4


2  

I think you should consult some introduction text on compilers, linkers and libraries, i.e. how the pieces come together when building a program. In essence the linker is telling you, that there are some loose ends and it cannot finish linking the program due to them. Adding a library happens by the -l switch with library name (GLU in your case), not by giving it a full path to the library file.

我认为您应该参考一些关于编译器、链接器和库的介绍文本,也就是在构建程序时如何组合。在本质上,链接器告诉你,有一些松散的结束,它不能完成连接程序,因为它们。添加一个库是由-l开关与库名称(在您的例子中是GLU)发生的,而不是通过给它一个完整的路径到库文件。

#5


0  

I got the exact same problem in Ubuntu 12.04 LTS when I wrote:

我在Ubuntu 12.04 LTS中遇到了同样的问题:

g++ square.cpp -lglut

But then I found on the web that some people also added -lGL and lGLU so I did it and it compiles now:

但是后来我在网上发现一些人也加入了-lGL和lGLU所以我做了,现在编译:

g++ square.cpp -lglut -lGL -GLU

#1


2  

You have to link some gl libraries.

你必须连接一些gl库。

g++ cube.c -o cube -I /usr/lib/libglut.so.3 /usr/lib/libGL.so.1 /usr/lib/libGLU.so.1 -lGL

#2


6  

Compile : g++ sampleCode.cpp -lglut -lGL -lGLU

编译:g++ sampleCode。cpp -lglut -lGL -lGLU

run : ./a.out

运行:. / a.o ut

is your answer.

是你的答案。

#3


2  

do what it says

做什么它说

gcc cube.c -o cube -lglut -lGLU

#4


2  

I think you should consult some introduction text on compilers, linkers and libraries, i.e. how the pieces come together when building a program. In essence the linker is telling you, that there are some loose ends and it cannot finish linking the program due to them. Adding a library happens by the -l switch with library name (GLU in your case), not by giving it a full path to the library file.

我认为您应该参考一些关于编译器、链接器和库的介绍文本,也就是在构建程序时如何组合。在本质上,链接器告诉你,有一些松散的结束,它不能完成连接程序,因为它们。添加一个库是由-l开关与库名称(在您的例子中是GLU)发生的,而不是通过给它一个完整的路径到库文件。

#5


0  

I got the exact same problem in Ubuntu 12.04 LTS when I wrote:

我在Ubuntu 12.04 LTS中遇到了同样的问题:

g++ square.cpp -lglut

But then I found on the web that some people also added -lGL and lGLU so I did it and it compiles now:

但是后来我在网上发现一些人也加入了-lGL和lGLU所以我做了,现在编译:

g++ square.cpp -lglut -lGL -GLU