简体   繁体   中英

Trouble building GLEW on Windows using MinGW

I'm trying to build GLEW 2.1.0 on Windows (8.1) using MinGW and have been struggling for a while now.

I tried to follow the instructions for "MSYS/Mingw" on the GLEW GitHub page but when running mingw32-make , I only got a couple errors about missing commands ( test and config ) as well as the following: Makefile:40: *** "Platform '' not supported". Stop. Makefile:40: *** "Platform '' not supported". Stop.

Under "Requirements" it says that bash is needed, so I installed git , because that apparently comes with a version of bash. Running mingw32-make (in the directory that all the GLEW files and folders are in) using Git Bash results in a long list of warnings and "undefined reference"s. The latter come from the linker as far as I know, but I have no idea what could cause them. As it's so much text, I'll only include the last few lines here:

c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0x181b): undefined reference to `_imp___iob'
collect2.exe: error: ld returned 1 exit status
Makefile:181: recipe for target 'bin/glewinfo.exe' failed
mingw32-make: *** [bin/glewinfo.exe] Error 1

mingw32-make install has the following output:

$ mingw32-make install
install -d -m 0755 "/usr/include/GL"
install -m 0644 include/GL/wglew.h "/usr/include/GL/"
install -m 0644 include/GL/glew.h "/usr/include/GL/"
install -m 0644 include/GL/glxew.h "/usr/include/GL/"
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@|2.1.0|g" \
        -e "s|@cflags@||g" \
        -e "s|@libname@|glew32|g" \
        -e "s|@requireslib@|glu|g" \
        < glew.pc.in > glew.pc
install -d -m 0755 "/usr/lib"
install -d -m 0755 "/usr/bin"
install -m 0755 lib/glew32.dll "/usr/bin/"
install -m 0644 lib/libglew32.dll.a    "/usr/lib/"
install -m 0644 lib/libglew32.a        "/usr/lib/"
install -d -m 0755 "/usr/lib/pkgconfig"
install -d -m 0755 "/usr/lib/pkgconfig"
install -m 0644 glew.pc "/usr/lib/pkgconfig/"

And mingw32-make install.all produces another long list of undefined references and the same error that came from running mingw32-make. The first lines however are (about) the same as the result of running mingw32-make install.

As expected with all of the errors, running these commands didn't produce a binary file. I guess it could have something to do with me not having make, which is one of the requirements listed on the GitHub page. However I don't understand how I should install make on Windows and why it is even needed when the instructions say to use mingw32-make.

I've also tried some of the suggestions made in this thread, but that doesn't seem to have worked either.

What could be the problem and what can I do to successfully compile GLEW?

I could never build it with the instructions I found around the internet, so here's how I build glew (using https://downloads.sourceforge.net/project/glew/glew/2.2.0/glew-2.2.0.tgz ) under MSYS2 with MinGW-w64:

# change the line below to your desired install path
INSTALLPREFIX=/usr/local
VERSION=2.2.0
gcc -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32.a src/glew.o &&
gcc -DGLEW_MX -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/glew.mx.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32mx.a src/glew.mx.o &&
gcc -O2 -c -Iinclude -o src/glewinfo.o src/glewinfo.c &&
gcc -s -o src/glewinfo.exe src/glewinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 &&
gcc -O2 -c -Iinclude -o src/visualinfo.o src/visualinfo.c &&
gcc -s -o src/visualinfo.exe src/visualinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 -lglu32 &&
sed -e "s?@prefix@?$INSTALLPREFIX?; s?@libdir@?\$\{prefix\}/lib?; s?@version@?$VERSION?; s?@requireslib@?glu?; s?@cflags@??; s?@libname@?glew32?" glew.pc.in > glew.pc &&
sed -e "s?@prefix@?$INSTALLPREFIX?; s?@libdir@?\$\{prefix\}/lib?; s?@version@?$VERSION?; s?@requireslib@?glu?; s?@cflags@?-DGLEW_MX?; s?@libname@?glew32mx?" glew.pc.in > glewmx.pc &&
echo Installing... &&
mkdir -p $INSTALLPREFIX/include $INSTALLPREFIX/lib/pkgconfig $INSTALLPREFIX/bin $INSTALLPREFIX/cmake &&
cp -rf include/GL $INSTALLPREFIX/include/ &&
cp -f lib/*.a $INSTALLPREFIX/lib/ &&
cp -f *.pc $INSTALLPREFIX/lib/pkgconfig/ &&
cp -f lib/*.dll src/*.exe $INSTALLPREFIX/bin/ &&
cp -f build/cmake/*.cmake $INSTALLPREFIX/cmake/ &&
echo Success

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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