2

我正在尝试从项目中编译示例,以下代码是makefile:

CC = g++
ifeq ($(shell sw_vers 2>/dev/null | grep Mac | awk '{ print $$2}'),Mac)
    CFLAGS = -g -DGL_GLEXT_PROTOTYPES -I./include/ -I/usr/X11/include -DOSX
    LDFLAGS = -framework GLUT -framework OpenGL -L./lib/mac/ \
        -L"/System/Library/Frameworks/OpenGL.framework/Libraries" \
        -lGL -lGLU -lm -lstdc++ -lGLEW -lfreeimage 
else
    CFLAGS = -g -DGL_GLEXT_PROTOTYPES -I./include/ -I/usr/X11R6/include -I/sw/include \
                     -I/usr/sww/include -I/usr/sww/pkg/Mesa/include
    LDFLAGS = -L./lib/nix -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib \
                        -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lGLEW -lfreeimage
endif

RM = /bin/rm -f 

all: mytest3
mytest3: mytest3.o shaders.o shaders.h geometry3.h
    $(CC) $(CFLAGS) -o mytest3 shaders.o mytest3.o $(INCFLAGS) $(LDFLAGS) 
mytest3.o: mytest3.cpp shaders.h geometry3.h
    $(CC) $(CFLAGS) $(INCFLAGS) -c mytest3.cpp
shaders.o: shaders.cpp
    $(CC) $(CFLAGS) $(INCFLAGS) -c shaders.cpp
clean: 
    $(RM) *.o mytest3 *.png

所以我尝试了:“make”,我得到了:

$ make
g++ -g -DGL_GLEXT_PROTOTYPES -I./include/ -I/usr/X11R6/include -I/sw/include -I/usr/sww/include -I/usr/sww/pkg/Mesa/include -o mytest3 shaders.o mytest3.o  -L./lib/nix -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lGLEW -lfreeimage                                                                                                                                                             
/usr/bin/ld: error: no se puede abrir /usr/lib/gcc/x86_64-linux-gnu/4.4.7/../../../x86_64-linux-gnu/libGL.so: No existe el archivo o el directorio                                                                              
shaders.cpp:37: error: undefined reference to 'glGetProgramiv'                                                                                                                                                                  
shaders.cpp:39: error: undefined reference to 'glGetProgramInfoLog'                                                                                                                                                             
shaders.cpp:46: error: undefined reference to 'glGetShaderiv'                                                                                                                                                                   
shaders.cpp:48: error: undefined reference to 'glGetShaderInfoLog'                                                                                                                                                              
shaders.cpp:57: error: undefined reference to 'glCreateShader'                                                                                                                                                                  
shaders.cpp:63: error: undefined reference to 'glShaderSource'                                                                                                                                                                  
shaders.cpp:64: error: undefined reference to 'glCompileShader'                                                                                                                                                                 
shaders.cpp:65: error: undefined reference to 'glGetShaderiv'                                                                                                                                                                   
shaders.cpp:75: error: undefined reference to 'glCreateProgram'                                                                                                                                                                 
shaders.cpp:77: error: undefined reference to 'glAttachShader'                                                                                                                                                                  
shaders.cpp:78: error: undefined reference to 'glAttachShader'                                                                                                                                                                  
shaders.cpp:79: error: undefined reference to 'glLinkProgram'                                                                                                                                                                   
shaders.cpp:80: error: undefined reference to 'glGetProgramiv'                                                                                                                                                                  
shaders.cpp:81: error: undefined reference to 'glUseProgram'                                                                                                                                                                    
geometry3.h:72: error: undefined reference to 'glBindBuffer'                                                                                                                                                                    
geometry3.h:73: error: undefined reference to 'glBufferData'                                                                                                                                                                    
geometry3.h:74: error: undefined reference to 'glVertexPointer'                                                                                                                                                                 
geometry3.h:75: error: undefined reference to 'glEnableClientState'                                                                                                                                                             
geometry3.h:76: error: undefined reference to 'glBindBuffer'                                                                                                                                                                    
geometry3.h:77: error: undefined reference to 'glBufferData'
geometry3.h:78: error: undefined reference to 'glColorPointer'
geometry3.h:79: error: undefined reference to 'glEnableClientState'
geometry3.h:80: error: undefined reference to 'glBindBuffer'
geometry3.h:81: error: undefined reference to 'glBufferData'
geometry3.h:101: error: undefined reference to 'glGenTextures'
geometry3.h:103: error: undefined reference to 'glBindBuffer'
geometry3.h:104: error: undefined reference to 'glBufferData'
geometry3.h:105: error: undefined reference to 'glActiveTexture'
geometry3.h:106: error: undefined reference to 'glEnable'
geometry3.h:107: error: undefined reference to 'glTexCoordPointer'
geometry3.h:108: error: undefined reference to 'glEnableClientState'
geometry3.h:110: error: undefined reference to 'glBindTexture'
geometry3.h:112: error: undefined reference to 'glTexImage2D'
geometry3.h:113: error: undefined reference to 'glTexParameterf'
geometry3.h:114: error: undefined reference to 'glTexParameterf'
geometry3.h:115: error: undefined reference to 'glTexParameteri'
geometry3.h:116: error: undefined reference to 'glTexParameteri'
geometry3.h:120: error: undefined reference to 'glGetUniformLocation'
geometry3.h:121: error: undefined reference to 'glUniform1i'
geometry3.h:122: error: undefined reference to 'glGetUniformLocation'
geometry3.h:130: error: undefined reference to 'glVertexPointer'
geometry3.h:131: error: undefined reference to 'glEnableClientState'
geometry3.h:147: error: undefined reference to 'glColorPointer'
geometry3.h:156: error: undefined reference to 'glVertexPointer'
geometry3.h:159: error: undefined reference to 'glColorPointer'
geometry3.h:162: error: undefined reference to 'glDrawElements'
geometry3.h:170: error: undefined reference to 'glVertexPointer'
geometry3.h:175: error: undefined reference to 'glColorPointer'
geometry3.h:178: error: undefined reference to 'glActiveTexture'
geometry3.h:179: error: undefined reference to 'glEnable'
geometry3.h:180: error: undefined reference to 'glBindTexture'
geometry3.h:183: error: undefined reference to 'glTexCoordPointer'
geometry3.h:186: error: undefined reference to 'glDrawElements'
geometry3.h:199: error: undefined reference to 'glDrawElements'
mytest3.cpp:54: error: undefined reference to 'glGetFloatv'
mytest3.cpp:67: error: undefined reference to 'glClear'
mytest3.cpp:78: error: undefined reference to 'glUniform1i'
mytest3.cpp:79: error: undefined reference to 'glUniform1i'
mytest3.cpp:82: error: undefined reference to 'glUniform1i'
mytest3.cpp:89: error: undefined reference to 'glMatrixMode'
mytest3.cpp:92: error: undefined reference to 'glPushMatrix'
mytest3.cpp:93: error: undefined reference to 'glTranslatef'
mytest3.cpp:95: error: undefined reference to 'glPopMatrix'
mytest3.cpp:98: error: undefined reference to 'glPushMatrix'
mytest3.cpp:98: error: undefined reference to 'glTranslatef'
mytest3.cpp:98: error: undefined reference to 'glPopMatrix'
mytest3.cpp:101: error: undefined reference to 'glPushMatrix'
mytest3.cpp:102: error: undefined reference to 'glTranslatef'
mytest3.cpp:104: error: undefined reference to 'glPopMatrix'
mytest3.cpp:107: error: undefined reference to 'glPushMatrix'
mytest3.cpp:108: error: undefined reference to 'glTranslatef'
mytest3.cpp:110: error: undefined reference to 'glPopMatrix'
mytest3.cpp:136: error: undefined reference to 'glUniform3fv'
mytest3.cpp:137: error: undefined reference to 'glUniform4fv'
mytest3.cpp:138: error: undefined reference to 'glUniform4fv'
mytest3.cpp:139: error: undefined reference to 'glUniform4fv'
mytest3.cpp:142: error: undefined reference to 'glUniform4fv'
mytest3.cpp:145: error: undefined reference to 'glUniform1fv'
mytest3.cpp:155: error: undefined reference to 'glColor3f'
mytest3.cpp:164: error: undefined reference to 'glRotatef'
mytest3.cpp:165: error: undefined reference to 'glRotatef'
mytest3.cpp:182: error: undefined reference to 'glFlush'
mytest3.cpp:218: error: undefined reference to 'glMatrixMode'
mytest3.cpp:219: error: undefined reference to 'glLoadIdentity'
mytest3.cpp:232: error: undefined reference to 'glMatrixMode'
mytest3.cpp:233: error: undefined reference to 'glLoadIdentity'
mytest3.cpp:253: error: undefined reference to 'glReadBuffer'
mytest3.cpp:254: error: undefined reference to 'glReadPixels'
mytest3.cpp:303: error: undefined reference to 'glViewport'
mytest3.cpp:304: error: undefined reference to 'glMatrixMode'
mytest3.cpp:305: error: undefined reference to 'glLoadIdentity'
mytest3.cpp:317: error: undefined reference to 'glClearColor'
mytest3.cpp:321: error: undefined reference to 'glLoadIdentity'
mytest3.cpp:336: error: undefined reference to 'glCreateProgram'
mytest3.cpp:339: error: undefined reference to 'glGetProgramiv'
mytest3.cpp:342: error: undefined reference to 'glGetUniformLocation'
mytest3.cpp:343: error: undefined reference to 'glGetUniformLocation'
mytest3.cpp:355: error: undefined reference to 'glGenBuffers'
mytest3.cpp:369: error: undefined reference to 'glEnable'
mytest3.cpp:370: error: undefined reference to 'glDepthFunc'
collect2: ld returned 1 exit status
make: *** [mytest3] Error 1

我安装了过剩:

$ find /usr -name glut.h
/usr/local/cuda-5.0/extras/CUPTI/include/GL/glut.h
/usr/local/cuda-5.0/samples/common/inc/GL/glut.h
/usr/include/GL/glut.h

$ locate libglut
/usr/lib/libglut.so
/usr/lib/gcc/x86_64-linux-gnu/4.4/libglut.so
/usr/lib/x86_64-linux-gnu/libglut.a
/usr/lib/x86_64-linux-gnu/libglut.so
/usr/lib/x86_64-linux-gnu/libglut.so.3
/usr/lib/x86_64-linux-gnu/libglut.so.3.9.0

所以我不知道为什么编译器正在搜索“gcc”路径,它应该可以正常工作......

我也试过:

sudo ln -s /usr/lib/x86_64-linux-gnu/libglut.so /usr/lib/gcc/x86_64-linux-gnu/4.4.7/libglut.so

但仍然无法正常工作。

我在 ubuntu 12.10 上,我首先安装了:

sudo apt-get install freeglut3-dev glew-utils libglew1.6-dev libfreeimage-dev
sudo apt-get install build-essential

怎么了?

4

1 回答 1

1

第一个错误:

/usr/bin/ld: 错误: 没有/usr/lib/gcc/x86_64-linux-gnu/4.4.7/../../../x86_64-linux-gnu/libGL.so: 没有Existe el archivo o el directory

您缺少 libGL。确保您的驱动程序/台面已正确安装。尝试

sudo apt-get install libgl1-mesa-dev
于 2013-03-22T17:42:06.717 回答