使用 mingw 使建筑物在 Windows 上闪闪发光
任何人都可以给我正确的命令来使用 mingw 在 Windows 上构建 glew 吗?
我尝试过:
gcc -static glew.c glewinfo.c Visualinfo.c -I/path/to/glew/include
但我收到了数千个链接器错误(缺少引用)。
我无法使用 Make 进行构建,因为不幸的是 makefile 有很多仅适用于 UNIX 的命令,而我没有 cygwin 或任何东西在工作。
(或者,如果有人可以向我指出 Windows 32b 版本,我将非常感激)
Can anyone give me the correct command to build glew on windows with mingw?
I have tried:
gcc -static glew.c glewinfo.c visualinfo.c -I/path/to/glew/include
but I am getting thousands of linker errors (missing reference).
I can't build with Make because unfortunately the makefile has lots of unix only commands and i don't have cygwin or anything at work.
(alternatively if anyone can point me to a windows 32b build i would be very grateful)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
要使用 MinGW 构建它,您应该执行以下操作(从 make 日志复制,稍加修改和附加说明):
然后您应该有一个 lib 文件夹和一个 bin 文件夹,其中包含所需的可执行文件和库
To build it with MinGW, you should do (copied from the make log, with slight modifications and additional explanations):
You should then have a lib folder and a bin folder with the desired executables and libraries
我让它工作(使用 MinGW),我没有编译 glew32mx 而是编译 glew32 。只需从 GLEW 网站下载源 .zip 即可。并记住在glew-1.xx目录中创建“lib”目录,否则在尝试编译下面的第二行代码时会抱怨“找不到/lib/glew32.dll”:The
precompiled binaries in GLEW网站不适用于 mingw,因为我认为它们是用 Visual Studio 编译的。
I got it working (with MinGW), i didn't compile the glew32mx but glew32 instead. Just download the source .zip from GLEW website. And remember create "lib" directory in the the glew-1.xx directory, otherwise it will complain about "can't find /lib/glew32.dll" when trying to compile the second line of code below:
The precompiled binaries in GLEW website doesn't work with mingw, because they're compiled with visual studio, i think.
找到了另一个适用于 Code::Blocks 的解决方案。步骤:
1)显然你需要glew源代码;)
2)用C::B打开glew_shared.dsw文件,编辑项目属性,对于你需要的每个构建目标,将其类型从“动态库”更改为“静态库” “(就在那里,在“构建目标”选项卡上)。您还可以更改目标目录,因为 .dll 文件内置于 bin\ 目录中。
3) 在 #include 之前添加 #define GLEW_STATIC
4) 构建目标,它将创建正确的 libglew32*.a
Found another solution that works with Code::Blocks. Steps:
1) Obviously you will need glew source code ;)
2) Open glew_shared.dsw files with C::B, edit project properties and, for each build target you need, change it's type from "Dynamic library" to "Static library" (it's right there, at Build targets tab). You can also change the destination directory as .dll files are built into bin\ directory.
3) Add #define GLEW_STATIC before #include
4) Build the target and it will result in proper libglew32*.a being created
Glew 构建系统尝试使用 config/configure.guess 自动检测您的环境。您可以通过指定
$SYSTEM
来重载此行为。请参阅 config/Makefile.* 了解所有受支持的构建配置。 Glew 已经包含使用 MinGW 的配置。所以,你可能只需要启动:
在我的 Fedora 上,我必须调整 config/Makefile.linux-mingw64 的一些变量:
$CC
和$LD
不正确最后,我启动了:
Glew build system try to detect automatically your environment using
config/configure.guess
. You may overload this behaviour by specify$SYSTEM
to make. Seeconfig/Makefile.*
for all supported build configuration. Glew already include configuration to use MinGW.So, you may just have to launch:
On my Fedora, I had to tune some variables of
config/Makefile.linux-mingw64
:$CC
and$LD
was not correctFinally, I launched:
除了 PoL0 的回答之外,我发现这些步骤确实对我在 Code::Blocks 上使用 MinGW 有效,但需要进行进一步的更改 - 默认项目在编译器选项下的“其他选项”中设置了很多微软的废话。清除这些,您将获得良好的结果(项目构建选项 -> [每个目标] -> 编译器设置选项卡 -> 其他选项子选项卡)
您可能还希望启用两个发布目标的优化(-O2 或-O3)。
此外,静态库默认构建在“bin”中,您需要复制/移动它们以替换“lib”中的静态库。
Further to PoL0's answer, i found those steps did work for me with MinGW on Code::Blocks but with one further alteration required - the default project has a lot of microsoft nonsense set in the "other options" under compiler options. Clear these and you'll have a good result (project build options -> [each target] -> compiler settings tab -> other options subtab)
You may also wish to enable optimisation for the two release targets (-O2 or -O3).
Additionally, the static libraries will be built in "bin" by default, you'll need to copy / move them to replace the ones in "lib".
以下是 VLC 如何在 mingw 上构建 glew(静态):
https://github .com/videolan/vlc/tree/master/contrib/src/glew(他们应用了该补丁)。猜猜glew没有简单的选择来“仅仅”构建一个静态库,所以你必须经历各种障碍(或手动编译,正如其他答案所提到的那样)。
另请参阅http://en.wikibooks.org/wiki/OpenGL_Programming/Installation/Windows #GLEW
和步骤 7:http://sujatha-techie.blogspot.com/2008/10/glsl-with-mingw.html
这就是 mx 的做法:https://github.com/mxe/mxe/blob/master/src/glew.mk (看起来他们基本上只是手动构建所有内容,glew 的 Makefile 似乎很弱......)
Here is how VLC builds glew (static) on mingw:
https://github.com/videolan/vlc/tree/master/contrib/src/glew (they apply that patch). Guess glew has no easy option to "just" build a static library so you have to go through various hurdles (or manually compile, as the other answers allude to).
See also http://en.wikibooks.org/wiki/OpenGL_Programming/Installation/Windows#GLEW
and step 7 here: http://sujatha-techie.blogspot.com/2008/10/glsl-with-mingw.html
This is how mx does it: https://github.com/mxe/mxe/blob/master/src/glew.mk (looks like they basically just manually build everything, glew's Makefile seems weak...)
我相信主要的 Glew 网站 在首页上有一个指向二进制文件的链接,用于 32 位 和 64位 Windows系统。
I believe the main Glew website has a link to the binaries on the front page, for 32-bit and 64-bit windows systems.
如果您安装了 MingW,只需运行 Msys 并 make 并在完成后进行安装,将库和包含文件夹复制到 bin 库并在 MingW 中包含文件夹,它应该一切正常,
简单而快速的解决方案
if you have MingW installed just run Msys and make and make install there once you finish copy the libs and include folders to the bin libs and include folders in MingW and it should all work fine
simple and fast solution