使用glutSwapBuffers()函数时,“找不到架构x86_64的符号”

时间:2014-08-22 11:41:08

标签: c++ macos opengl linker glut

我正在为我的OpenGL程序中的窗口编写显示功能。我的功能如下:

void window::display() {
    glClear(GL_COLOR_BUFFER_BIT);
    // Loop to draw all particles here
    glutSwapBuffers();
}

然而,当我编译程序时,我收到以下错误:

Undefined symbols for architecture x86_64:
  "_glutSwapBuffers", referenced from:
      window::display() in window.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我已经因使用glClear(GL_COLOR_BUFFER_BIT)而遇到此错误,并且能够通过在编译时添加-framework OpenGL标志来修复它。这个问题令我感到困惑,因为glutSwapBuffers()是一个GLUT的东西,而不是一个OpenGL的东西,所以我不知道我是否可以用同样的方式修复它,甚至我怎么做。一些可能有用的附加信息:我在Mac OSX 10.9.4上,我在所有需要它们的文件中包含了“OpenGL / gl.h”,“OpenGL / glu.h”和“GLUT / glut.h” ,我的makefile看起来像这样......

COMPILECPP  = g++ -g -O0 -Wall -Wextra -framework OpenGL -std=c++11
CPPSOURCE   = window.cpp main.cpp
EXECBIN     = psys
OBJECTS     = ${CPPSOURCE:.cpp=.o}

all : ${EXECBIN}

${EXECBIN} : ${OBJECTS}
    ${COMPILECPP} -o $@ ${OBJECTS}

%.o : %.cpp
    ${COMPILECPP} -c $<

0 个答案:

没有答案