Home > Backend Development > C++ > body text

How to Build GLEW on Windows with MinGW?

Susan Sarandon
Release: 2024-10-26 06:21:03
Original
343 people have browsed it

How to Build GLEW on Windows with MinGW?

Building GLEW on Windows with MinGW

Attempting to build GLEW on Windows with MinGW using the command gcc -static glew.c glewinfo.c visualinfo.c -I/path/to/glew/include may result in numerous linker errors due to missing references.

Instead, the appropriate command to build GLEW is as follows (modified from the make log for clarity):

  1. Define GLEW Properties and Compile GLEW

    mkdir lib/
    mkdir bin/
    gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude  -DGLEW_BUILD -o src/glew.o -c src/glew.c
    Copy after login
  2. Build Shared Library (DLL)

    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
    Copy after login
  3. Create Static Library

    ar cr lib/libglew32.a src/glew.o
    Copy after login
  4. Create Pkg-Config File (Optional)

    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
    Copy after login
  5. Build MEX Version of GLEW

    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
    Copy after login
  6. Create Pkg-Config File for MEX Version (Optional)

    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
    Copy after login
  7. Build Utility Programs (Optional)

    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
    Copy after login

Following these steps should result in a successful build of GLEW and its associated executables and libraries into the lib and bin folders.

The above is the detailed content of How to Build GLEW on Windows with MinGW?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!