I cannot find the folder C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\gl on my laptop. How do I add it?

时间:2015-09-30 23:13:14

标签: c++ visual-studio opengl

Also does that mean opengl is not installed by default because I did check all the boxes when I installed visual studio community 2015. I couldn't find any clear answer anywhere. I'm supposed to add glut and glew header files to the aforementioned folder where gl.h and glu.h should already be there. But I couldnt find the folder include\gl itself.

1 个答案:

答案 0 :(得分:1)

  

这也意味着默认情况下没有安装opengl,因为我在安装visual studio community 2015时检查了所有方框。我无法在任何地方找到任何明确的答案。

您必须区分:

  • 正在安装一个功能齐全的OpenGL驱动程序(不幸的是,在Windows上默认不会发生这种情况)

  • 可供编译环境使用的OpenGL开发支持文件。

就编译器环境而言,由于OpenGL-1.1已经成为Windows-NT-4以来的Windows ABI合同的一部分,所有针对Windows-32 API 的编译器必须随附所需的支持文件。

要检查编译器安装是否完整,请尝试编译并执行以下小程序:

#include <windows.h>
#include <GL/gl.h>
#include <stdio.h>

#pragma comment(lib, "opengl32.lib")

int main(int argc, char *argv[])
{
    if( &glGetError ) {
        fprintf(stderr, "OpenGL glGetError symbol available\n");
    }
}

它实际上并不调用OpenGL函数,但编译它需要链接到opengl32.lib并测试符号glGetError是非NULL确保链接器将引入引用。

  

我应该将过剩的头文件添加到上述文件夹

唐&#39;吨! 从不手动将任何内容放入编译器工具链的安装目录中。 始终为标题和库文件配置辅助目录结构,并将其添加到项目中。编译器包含和链接器搜索路径。

在那里安装GLEW。如果您已获得将GLEW安装到编译器工具链目录中的说明,请忽略来自同一来源的任何其他建议,因为无论谁是源,显然对正确的DevOps一无所知。

由于评论中的问题而更新

在使用第三方库的软件开发中很常见。您通常希望在公共位置收集这些库。这些库通常由头文件,二进制文件和一些操作系统上的附加链接器存根组成。二进制文件是为特定的操作系统构建的,链接器存根是为特定的编译器而创建的。

以下是这样的目录结构,受到* nix操作系统组织其内容的方式的启发

  • /local/include/获取所有标题
  • /local/i686-windows/bin 32位Windows额外工具可执行文件
  • /local/i686-pc-linux-gnu/bin 32位Linux额外工具可执行文件
  • /local/i686-windows/lib 32位Windows DLL
  • /local/i686-windows/libmsvc 32位Visual C ++链接器存根和静态库
  • /local/i686-windows/libmingw 32位GNU MinGW链接器存根和静态库
  • /local/i686-pc-linux-gnu/lib 32位Linux SO和静态库
  • /local/x86_64-windows/bin 64位Windows额外工具可执行文件
  • /local/x86_64-pc-linux-gnu/bin 64位Linux额外工具可执行文件
  • /local/x86_64-windows/lib 64位Windows DLL
  • /local/x86_64-windows/libmsvc 32位Visual C ++链接器存根和静态库
  • /local/x86_64-windows/libmingw 32位GNU MinGW链接器存根和静态库
  • /local/x86_64-linux-gnu/lib 64位Linux SO和静态库

好的,所以对于简单的开发环境,上面的列表可能有点过分。但是,假设你使用Visual C ++编译器定位64位Windows,那么你就创建了一个目录结构

  • /local/include/
  • /local/x86_64-windows/bin
  • /local/x86_64-windows/lib
  • /local/x86_64-windows/libmsvc

您要在GL/glut.h下添加GL/glew.h/local/include(以及其他标题文件),例如

/local/include/GL/glxew.h
/local/include/GL/glew.h
/local/include/GL/glut.h
/local/include/GL/wglew.h

您放入.lib的{​​{1}}个文件和/local/x86_64-windows/libmsvc中的DLL。然后在项目构建设置中,您只需添加/local/x86_64-windows/lib作为链接器搜索路径。对于DLL,您应该将/local/x86_64-windows/libmsvc添加到系统环境/local/x86_64-windows/lib变量中,以便在执行您构建的程序时找到它们。对于那些程序的部署,请复制EXE文件旁边所需的DLL。