简体   繁体   English

使用 mingw32 在窗户上发光

[英]Building glew on windows with mingw32

It is a duplicate and I am sorry about it but I don't have any other options because I can't make comments on answers and they didn't solved my problem.这是重复的,我很抱歉,但我没有任何其他选择,因为我无法对答案发表评论,而且他们没有解决我的问题。 Here is the original post:以下是原帖:

Building glew on windows with mingw 使用 mingw 在窗户上发光的建筑物

And here is my problem:这是我的问题:

1) When I try @LightningIsMyName's answer I get this error: 1) 当我尝试@LightningIsMyName 的回答时,我收到此错误:

Makefile:1: *** missing seperator. Makefile:1: *** 缺少分隔符。 Stop.停止。

2) When I try @anon's answer I get this error: 2) 当我尝试@anon 的回答时,我收到此错误:

Makefile:1: Makefile:1: *** commands commence before first target. Makefile:1: Makefile:1: *** 命令在第一个目标之前开始。 Stop.停止。

People says this andswer helped them but they didn't worked for me.人们说这个答案对他们有帮助,但他们对我不起作用。 I apogilize I duplicae a question somehow but I have no other chance with reputation limit for commenting.我道歉我以某种方式重复了一个问题,但我没有其他机会发表评论。 Hope you help.希望你有所帮助。 Thanks.谢谢。

I have performed many searches in order to find an answer to my problems.我进行了许多搜索以找到我的问题的答案。 It took a lot of time so I am posting it here to help others.花了很多时间,所以我在这里发布它以帮助其他人。

To make GLEW work with MinGW you should download the source from GLEW website and put要使 GLEW 与 MinGW 一起工作,您应该从 GLEW 网站下载源代码并将

gcc.exe from MinGW\\bin来自 MinGW\\bin 的 gcc.exe
ar.exe from MinGW32\\mingw32\\bin来自 MinGW32\\mingw32\\bin 的 ar.exe

to GLEW's source folder and create and run a .bat in that folder like that:到 GLEW 的源文件夹,然后在该文件夹中创建并运行 .bat 文件,如下所示:

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

you will get your .dll and .a files in lib folder.您将在 lib 文件夹中获得 .dll 和 .a 文件。 Put .dll files to system32 folder and put .a files to MinGW lib folder.将 .dll 文件放入 system32 文件夹,将 .a 文件放入 MinGW lib 文件夹。

Finally, if you are using SFML, link SFML libraries before GLEW and at last link OpenGL.最后,如果您使用 SFML,请在 GLEW 之前链接 SFML 库,最后链接 OpenGL。 If you change the linking order you will get a linker error.如果您更改链接顺序,您将收到链接器错误。

Don't forget to call glewInit() after creating your window.创建窗口后不要忘记调用glewInit()。

If you can't get it work in that way try mine (for Borland compilers):如果你不能以这种方式工作,试试我的(对于 Borland 编译器):

  1. download GLEW source code (not the binaries)下载GLEW源代码(不是二进制文件)

    • glew.c source code mine is ~900KB (I think GLEW 1.6) glew.c源代码是~900KB(我认为GLEW 1.6)
    • glew.h header mine is ~900KB (I think GLEW 1.6) glew.h标头是 ~900KB(我认为 GLEW 1.6)
  2. I use local project path to store GLEW我使用本地项目路径来存储 GLEW

    I know it is redundant but I do not need to make changes after system changes like reinstall OS or new compiler version etc... but to get it work you need to do some changes inside glew.c :我知道它是多余的,但我不需要在系统更改(例如重新安装操作系统或新编译器版本等)后进行更改……但要使其正常工作,您需要在glew.c进行一些更改:

    • change #include <glew.h> to #include "glew.h"#include <glew.h>更改为#include "glew.h"

    if you want to use global path then add it to your compiler,copy the files there and leave the <> as are如果你想使用全局路径然后将它添加到你的编译器,复制那里的文件并保持<>不变

  3. copy these 2 files to your project将这 2 个文件复制到您的项目中

    this is how to correctly include it into project just add this to your main source file (where your winmain or main function is):这是将它正确包含到项目中的方法,只需将其添加到您的主源文件(您的 winmain 或 main 函数所在的位置):

     #include <windows.h> // optional windows #include <math.h> // optional #define GLEW_STATIC // this configure header and source of GLEW to compile correctly #include "glew.c" // header is included inside so no need to duplicate include // here are the OpenGL includes like: gl.h,glext.h,....
  4. Now it should work现在它应该工作

    do not forget to call glewInit();不要忘记调用glewInit(); after OpenGL is initialized and before any extension is used ...在 OpenGL 初始化之后和使用任何扩展之前......

Try these commands:试试这些命令:
1: gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c 1: gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c
2: 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 2: 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
3: ar cr lib/libglew32.a src/glew.o 3: ar cr lib/libglew32.a src/glew.o

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM