在SDL项目中调用OpenGL函数导致它无法在OSX下编译

时间:2017-07-22 10:18:57

标签: xcode macos opengl sdl-2

我在Xcode 8.3.2中使用SDL2(最新的OSX二进制文件),C ++和OpenGL。如果我只是从代码中调用SDL2函数,那么该项目可以很好地构建。但是,当我在代码中包含任何OpenGL函数调用时,它无法编译。我已在文件头中包含<OpenGL/gl3.h>。但是,每当我在代码中调用任何OpenGL方法时,我在编译期间都会收到以下错误:

enter image description here 相关代码:

在Display.h中

#ifndef Display_h
#define Display_h

#include <iostream>
#include <SDL2/SDL.h>
#include <OpenGL/gl3.h>
...
Display.cpp中的

void Display::Clear(float r, float g, float b, float a)
{
   glClearColor(r,g,b,a);
}

我正在运行OSX 10.12

1 个答案:

答案 0 :(得分:0)

问题已经解决了。我需要在&#34; Build Phases&#34;下添加OpenGL框架。 &GT; &#34; Link Binary with Libraries&#34;该项目。我已经为SDL2做了那个。但是我也不知道我也需要为OpenGL做同样的事情。

相关问题