使用 mingw 使建筑物在 Windows 上闪闪发光

发布于 2024-11-06 22:24:51 字数 324 浏览 4 评论 0原文

任何人都可以给我正确的命令来使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

转身以后 2024-11-13 22:24:51

要使用 MinGW 构建它,您应该执行以下操作(从 make 日志复制,稍加修改和附加说明):

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

# Create library file: lib/libglew32.dll.a
ar cr lib/libglew32.a src/glew.o

# Create pkg-config file (optional if you just want a lib)
sed \
                -e "s|@prefix@|/usr|g" \
                -e "s|@libdir@|/usr/lib|g" \
                -e "s|@exec_prefix@|/usr/bin|g" \
                -e "s|@includedir@|/usr/include/GL|g" \
                -e "s|@version@|1.6.0|g" \
                -e "s|@cflags@||g" \
                -e "s|@libname@|GLEW|g" \
                < glew.pc.in > glew.pc

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

# Create library file: lib/libglew32mx.dll.a
ar cr lib/libglew32mx.a src/glew.mx.o

# Create pkg-config file (optional if you just want a lib)
sed \
                -e "s|@prefix@|/usr|g" \
                -e "s|@libdir@|/usr/lib|g" \
                -e "s|@exec_prefix@|/usr/bin|g" \
                -e "s|@includedir@|/usr/include/GL|g" \
                -e "s|@version@|1.6.0|g" \
                -e "s|@cflags@|-DGLEW_MX|g" \
                -e "s|@libname@|GLEWmx|g" \
                < glew.pc.in > glewmx.pc

# Make the glew visualinfo program. Skip this if you want just the lib
gcc -c -O2 -Wall -W -Iinclude  -o src/glewinfo.o src/glewinfo.c
gcc -O2 -Wall -W -Iinclude  -o bin/glewinfo.exe src/glewinfo.o -Llib  -lglew32 -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
gcc -c -O2 -Wall -W -Iinclude  -o src/visualinfo.o src/visualinfo.c
gcc -O2 -Wall -W -Iinclude  -o bin/visualinfo.exe src/visualinfo.o -Llib  -lglew32 -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32

然后您应该有一个 lib 文件夹和一个 bin 文件夹,其中包含所需的可执行文件和库

To build it with MinGW, you should do (copied from the make log, with slight modifications and additional explanations):

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

# Create library file: lib/libglew32.dll.a
ar cr lib/libglew32.a src/glew.o

# Create pkg-config file (optional if you just want a lib)
sed \
                -e "s|@prefix@|/usr|g" \
                -e "s|@libdir@|/usr/lib|g" \
                -e "s|@exec_prefix@|/usr/bin|g" \
                -e "s|@includedir@|/usr/include/GL|g" \
                -e "s|@version@|1.6.0|g" \
                -e "s|@cflags@||g" \
                -e "s|@libname@|GLEW|g" \
                < glew.pc.in > glew.pc

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

# Create library file: lib/libglew32mx.dll.a
ar cr lib/libglew32mx.a src/glew.mx.o

# Create pkg-config file (optional if you just want a lib)
sed \
                -e "s|@prefix@|/usr|g" \
                -e "s|@libdir@|/usr/lib|g" \
                -e "s|@exec_prefix@|/usr/bin|g" \
                -e "s|@includedir@|/usr/include/GL|g" \
                -e "s|@version@|1.6.0|g" \
                -e "s|@cflags@|-DGLEW_MX|g" \
                -e "s|@libname@|GLEWmx|g" \
                < glew.pc.in > glewmx.pc

# Make the glew visualinfo program. Skip this if you want just the lib
gcc -c -O2 -Wall -W -Iinclude  -o src/glewinfo.o src/glewinfo.c
gcc -O2 -Wall -W -Iinclude  -o bin/glewinfo.exe src/glewinfo.o -Llib  -lglew32 -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
gcc -c -O2 -Wall -W -Iinclude  -o src/visualinfo.o src/visualinfo.c
gcc -O2 -Wall -W -Iinclude  -o bin/visualinfo.exe src/visualinfo.o -Llib  -lglew32 -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32

You should then have a lib folder and a bin folder with the desired executables and libraries

暮色兮凉城 2024-11-13 22:24:51

我让它工作(使用 MinGW),我没有编译 glew32mx 而是编译 glew32 。只需从 GLEW 网站下载源 .zip 即可。并记住在glew-1.xx目录中创建“lib”目录,否则在尝试编译下面的第二行代码时会抱怨“找不到/lib/glew32.dll”:The

    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

    # Create glew32.dll
    ar cr lib/libglew32.a src/glew.o

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:

    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

    # Create glew32.dll
    ar cr lib/libglew32.a src/glew.o

The precompiled binaries in GLEW website doesn't work with mingw, because they're compiled with visual studio, i think.

爱殇璃 2024-11-13 22:24:51

找到了另一个适用于 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

撩动你心 2024-11-13 22:24:51

Glew 构建系统尝试使用 config/configure.guess 自动检测您的环境。您可以通过指定 $SYSTEM 来重载此行为。请参阅 config/Makefile.* 了解所有受支持的构建配置。 Glew 已经包含使用 MinGW 的配置。

所以,你可能只需要启动:

make SYSTEM=linux-mingw64

在我的 Fedora 上,我必须调整 config/Makefile.linux-mingw64 的一些变量:

  • $CC$LD 不正确
  • 我必须指定系统库所在的目录
  • 我必须指定 glew 的安装位置

最后,我启动了:

make SYSTEM=linux-mingw64                                       \
  CC=x86_64-w64-mingw32-gcc LD=x86_64-w64-mingw32-ld            \
  LDFLAGS.EXTRA=-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib    \
  GLEW_DEST=/usr/x86_64-w64-mingw32/sys-root/mingw install

Glew build system try to detect automatically your environment using config/configure.guess. You may overload this behaviour by specify $SYSTEM to make. See config/Makefile.* for all supported build configuration. Glew already include configuration to use MinGW.

So, you may just have to launch:

make SYSTEM=linux-mingw64

On my Fedora, I had to tune some variables of config/Makefile.linux-mingw64:

  • $CC and $LD was not correct
  • I had to specify directory where system libraries was located
  • I had to specify where glew should be installed

Finally, I launched:

make SYSTEM=linux-mingw64                                       \
  CC=x86_64-w64-mingw32-gcc LD=x86_64-w64-mingw32-ld            \
  LDFLAGS.EXTRA=-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib    \
  GLEW_DEST=/usr/x86_64-w64-mingw32/sys-root/mingw install
可是我不能没有你 2024-11-13 22:24:51

除了 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".

尬尬 2024-11-13 22:24:51

以下是 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...)

遮云壑 2024-11-13 22:24:51

我相信主要的 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.

吾性傲以野 2024-11-13 22:24:51

如果您安装了 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文