g++ linker: /usr/lib/libGL.so.1: could not read symbols: Invalid operation

被刻印的时光 ゝ 提交于 2019-11-30 03:23:00

问题


I'm trying to build a very simple OpenGL-app under Ubuntu 10.04 (I have a 32 bit system).

When I'm trying to compile the file, I get the error message:

g++ -L/usr/lib simple.cpp -lglut
/usr/bin/ld: /tmp/ccoPczAo.o: undefined reference to symbol 'glEnd'
/usr/bin/ld: note: 'glEnd' is defined in DSO //usr/lib/libGL.so.1 so try adding it to the linker command line
//usr/lib/libGL.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

Does anybody know what I'm doing wrong?


回答1:


You need to include the opengl library on the command line as well as the glut library/. Try adding -lGL to the end of your command line

g++ -L/usr/lib simple.cpp -lglut -lGL



回答2:


compile with

g++ main.cpp -o main.bin -lGL -lGLU -lglut

or Try the following make file from OpenGL primer it is very compact. This one helped me to run my Hello world OpenGL. Thanks to OpenGL Primer

CC = g++
SRC = main.cpp imageloader.cpp
LIBS = -lGL -lGLU -lglut
EXEC = cube.bin

all:
       $(CC) $(SRC) -o $(EXEC) $(LIBS)

clean:
       rm -rf $(EXEC) *~


来源:https://stackoverflow.com/questions/3476869/g-linker-usr-lib-libgl-so-1-could-not-read-symbols-invalid-operation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!