• <legend id='21bwK'><style id='21bwK'><dir id='21bwK'><q id='21bwK'></q></dir></style></legend>
    1. <i id='21bwK'><tr id='21bwK'><dt id='21bwK'><q id='21bwK'><span id='21bwK'><b id='21bwK'><form id='21bwK'><ins id='21bwK'></ins><ul id='21bwK'></ul><sub id='21bwK'></sub></form><legend id='21bwK'></legend><bdo id='21bwK'><pre id='21bwK'><center id='21bwK'></center></pre></bdo></b><th id='21bwK'></th></span></q></dt></tr></i><div id='21bwK'><tfoot id='21bwK'></tfoot><dl id='21bwK'><fieldset id='21bwK'></fieldset></dl></div>

    2. <tfoot id='21bwK'></tfoot>
      • <bdo id='21bwK'></bdo><ul id='21bwK'></ul>

      <small id='21bwK'></small><noframes id='21bwK'>

        使用 MinGW、freeglut 和 glew 编译简单的静态 OpenGL

        时间:2023-08-01
          <tbody id='k71pM'></tbody>

        • <small id='k71pM'></small><noframes id='k71pM'>

          <legend id='k71pM'><style id='k71pM'><dir id='k71pM'><q id='k71pM'></q></dir></style></legend>
        • <tfoot id='k71pM'></tfoot>
          • <bdo id='k71pM'></bdo><ul id='k71pM'></ul>

                  <i id='k71pM'><tr id='k71pM'><dt id='k71pM'><q id='k71pM'><span id='k71pM'><b id='k71pM'><form id='k71pM'><ins id='k71pM'></ins><ul id='k71pM'></ul><sub id='k71pM'></sub></form><legend id='k71pM'></legend><bdo id='k71pM'><pre id='k71pM'><center id='k71pM'></center></pre></bdo></b><th id='k71pM'></th></span></q></dt></tr></i><div id='k71pM'><tfoot id='k71pM'></tfoot><dl id='k71pM'><fieldset id='k71pM'></fieldset></dl></div>
                  本文介绍了使用 MinGW、freeglut 和 glew 编译简单的静态 OpenGL 4.0 程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  问题出在标题上,我会尽量在下面列出我已经尝试过的等等.

                  The problem is in the title, I'll try to list what I've already tried and so on below.

                  首先,根据我的理解,为了在 Windows 上使用 OpenGL 4.0,您必须扩展和/或绕过默认的 Windows 库,因为它只提供 OpenGL 1.1.

                  First off, in my understanding, in order to use OpenGL 4.0 on windows you must extend and or bypass the default windows library as it only ships OpenGL 1.1.

                  所以我们在 C:/MinGW/ 安装了 MinGW.接下来我通过下载 tarball 来自 项目站点.根据说明运行makefile来提取和编译,并添加少量--prefix./configure 命令.

                  So we have MinGW installed at C:/MinGW/. Next I setup FreeGLUT by downloading the tarball from the project site. Extract and compile by running the makefiles according to the instructions with a minor addition of --prefix to the ./configure command.

                  ./configure --prefix=/c/Users/Owner/root/
                  make all
                  make install 
                  

                  现在我在 /c/Users/Owner/root/lib//c/Users/Owner/root/include/ 等中有 freeglut.接下来是 GLEW,据我所知,我的问题孩子.

                  Now I have freeglut in /c/Users/Owner/root/lib/, /c/Users/Owner/root/include/ and so on. Next up is GLEW, my problem child as far as I can tell.

                  从项目站点(直接 1.7.0.zip 链接).编译有点复杂,我目前的配方来自堆栈溢出问题在 Windows 上构建 glew与 mingw".下面列出了一个缩写形式:

                  Download the source archive from the project site (direct 1.7.0.zip link). Compiling is a tad more complicated, my current recipe is derived from the stack overflow question " Building glew on windows with mingw ". An abbreviated form is listed below:

                  mkdir lib/
                  mkdir bin/
                  gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c
                  gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
                  ar cr lib/libglew32.a src/glew.o
                  gcc -DGLEW_NO_GLU -DGLEW_MX -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c
                  gcc -shared -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/glew.mx.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
                  ar cr lib/libglew32mx.a src/glew.mx.o
                  

                  并且应该从 /path/to/glew-1.7.0/ 的根"运行.

                  and should be run from the "root" of /path/to/glew-1.7.0/.

                  现在库的设置完成"(假设没有错误......)编译我的简单程序是用这一行完成的.

                  Now with setup of libraries "done" (assuming no mistakes... ) compiling my simple program is done with this line.

                  ${G++}  -DFREEGLUT_STATIC -DGLEW_STATIC -m32 main.cpp -o main.exe -lfreeglut_static -lopengl32 -lwinmm -lgdi32 -lglew32  -I ${ROOTPATH}/include -L ${ROOTPATH}/lib --static
                  

                  现在稍微分解一下并解释为什么我有各种额外"参数,并向您展示我已经遇到并解决了哪些错误和问题.

                  Now to decompose this a bit and walk through why I have various "extra" arguments and to show you what errors and problems I've already run into and solved.

                    使用
                  1. -DFREEGLUT_STATIC-lfreeglut_static 代替普通的 -lfreeglut ,因为我们在这里需要静态构建.不这样做会导致与 freeglut 相关的链接器错误.
                  2. -DGLEW_STATIC 也是出于同样的原因添加的.
                  3. 添加
                  4. -lwinmm 以修复链接器错误:freeglut_init.c:(.text+0x5d9): undefined reference to '_timeBeginPeriod@4'.
                  5. 添加
                  6. -lgdi32 以修复链接器错误:c:/Users/Owner/root//liblibfreeglut_static.a(freeglut_init.o):freeglut_init.c:(.text+0x58c): 对'_GetDeviceCaps@8'的未定义引用
                  1. -DFREEGLUT_STATIC and -lfreeglut_static are used instead of the normal -lfreeglut as we want a static build here. Failure to do this gives linker errors relating to freeglut.
                  2. -DGLEW_STATIC is added for the same reason.
                  3. -lwinmm is added to fix the linker error: freeglut_init.c:(.text+0x5d9): undefined reference to '_timeBeginPeriod@4'.
                  4. -lgdi32 is added to fix the linker error: c:/Users/Owner/root//liblibfreeglut_static.a(freeglut_init.o):freeglut_init.c:(.text+0x58c): undefined reference to '_GetDeviceCaps@8'

                  现在我被以下链接器错误难住了:

                  Now I'm stumped with the following linker error:

                  c:/Users/Owner/root//liblibglew32.a(glew.o):glew.c:(.text+0x83e8): undefined reference to `_glGetString@4'
                  c:/Users/Owner/root//liblibglew32.a(glew.o):glew.c:(.text+0xa1b2): undefined reference to `_glGetString@4'
                  c:/Users/Owner/root//liblibglew32.a(glew.o):glew.c:(.text+0xa290): undefined reference to `_glGetString@4'
                  

                  产生此错误的最小测试用例 (main.cpp) 是.

                  The minimal test case that produces this error (main.cpp) is.

                  #include <GL/glew.h>
                  #include <GL/freeglut.h>
                  
                  int main(int argc, char **argv) {
                    glEnableVertexAttribArray(0);
                  }
                  

                  想法?

                  推荐答案

                  尝试在最后一行添加 -lopengl32 以编译您的程序,看看是否有帮助.

                  Try adding -lopengl32 last on the line to compile your program and see if it helps.

                  这篇关于使用 MinGW、freeglut 和 glew 编译简单的静态 OpenGL 4.0 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:加载 DLL 不初始化静态 C++ 类 下一篇:在 Windows 控制台中获取按键

                  相关文章

                  最新文章

                  1. <i id='q8MDB'><tr id='q8MDB'><dt id='q8MDB'><q id='q8MDB'><span id='q8MDB'><b id='q8MDB'><form id='q8MDB'><ins id='q8MDB'></ins><ul id='q8MDB'></ul><sub id='q8MDB'></sub></form><legend id='q8MDB'></legend><bdo id='q8MDB'><pre id='q8MDB'><center id='q8MDB'></center></pre></bdo></b><th id='q8MDB'></th></span></q></dt></tr></i><div id='q8MDB'><tfoot id='q8MDB'></tfoot><dl id='q8MDB'><fieldset id='q8MDB'></fieldset></dl></div>
                    <legend id='q8MDB'><style id='q8MDB'><dir id='q8MDB'><q id='q8MDB'></q></dir></style></legend>

                    <small id='q8MDB'></small><noframes id='q8MDB'>

                    • <bdo id='q8MDB'></bdo><ul id='q8MDB'></ul>
                    <tfoot id='q8MDB'></tfoot>