如何在 xcode 中链接 glew

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17600917/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:36:06  来源:igfitidea点击:

How to link glew in xcode

c++xcodemacosopenglglew

提问by user2417329

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

我无法将 glew 与 xcode 联系起来。我有glew库位于/usr/local/lib/libGLEW.dylib

When i compile file in command line all right:

当我在命令行中编译文件时:

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

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

But when i compile in xcode, i get error:

但是当我在 xcode 中编译时,出现错误:

'GL/glew.h' file not found

找不到“GL/glew.h”文件

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

我用 xcode 链接了 glew

there screenshot

有截图

OS X 10.8.4, Xcode 4.6.1

OS X 10.8.4,Xcode 4.6.1

回答by Justin Meiners

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.

添加库只处理二进制链接。您需要配置 Xcode,以便它还可以找到描述二进制文件内容的标头。

In Xcode Project Settings search for: Header Search Paths

在 Xcode 项目设置中搜索: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.

将路径添加到 GLEW 的头文件中(可能在与库相同的文件夹附近,可能是 /usr/local/include)。更改导入以匹配。如果路径设置正确,它应该是#include <glew.h>(#include <GL/glew.h>)。

For Xcode beginners, here is a screenshot:

对于Xcode初学者,这是一个截图:

screenshot

截屏