How to link glew in xcode

user2417329 picture user2417329 · Jul 11, 2013 · Viewed 17.6k times · Source

I can't link glew with xcode. I have glew library is located in /usr/local/lib/libGLEW.dylib

When i compile file in command line all right:

g++ /usr/local/lib/libGLEW.dylib -framework OpenGL main.cpp

But when i compile in xcode, i get error:

'GL/glew.h' file not found

Code:

#include <iostream>
#include <GL/glew.h>

int main(int argc, const char * argv[])
{
    // insert code here...
    std::cout << "Hello, World!\n";
    return 0;
}

Im linked glew with xcode

there screenshot

OS X 10.8.4, Xcode 4.6.1

Answer

Justin Meiners picture Justin Meiners · Jul 11, 2013

Adding the library only handles the binary linking. You need to configure Xcode so it can also find the headers describing the contents of the binary.

In Xcode Project Settings search for: Header Search Paths

Add the path to the headers for GLEW (probably near the same folder as the library maybe /usr/local/include). Change the import to match. It should be #include <glew.h> (or #include <GL/glew.h>) if the path gets setup correctly.

For Xcode beginners, here is a screenshot:

screenshot