I've downloaded the source files for GLEW and have read/watched a few tutorials for compiling them. One method I saw involved creating a batch file to do the work, and someone was kind enough to type out the exact commands to put into the batch file. That seemed like the most fool-proof option, so I went with it, but am now getting compile-time errors from running the commands given, which other people apparently had success with.
Before I go further, here are some relevant details:
I'm using MinGW with the Code::Blocks IDE, running on Windows 10 (64 bit, if that matters to you). More information can and will be provided upon request.
I added the MinGW\bin directory to the Path environment variable, extracted the *.tgz file to a directory on my C: drive, and created within that same directory a batch file with the following contents, copied and pasted directly from the original source:
1 2 3 4 5 6 7
|
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
|
The only modification I made to the above is that I added a pause command to the end so that I could see the results, as otherwise the console window vanishes immediately upon executing the commands in the batch file.
Running this batch job results in the following output:
C:\GLEW>gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c
C:\GLEW>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
src/glew.o:glew.c(.text+0x28f80): multiple definition of `DllMainCRTStartup@12'
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../dllcrt2.o:dllcrt1.c:(.text+0x60): first defined here
collect2.exe: error ld returned 1 exit status
C:\GLEW>ar cr lib/libglew32.a src/glew.o
C:\GLEW>gcc -DGLEW_NO_GLU -DGLEW_MX -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c
C:\GLEW>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
src/glew.mx.o:glew.c:(.text+0x28f80): multiple definition of `DllMainCRTStartup@12'
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../dllcrt2.o:dllcrt1.c:(.text+0x60): first defined here
collect2.exe: error ld returned 1 exit status
C:\GLEW>ar cr lib/libglew32mx.a src/glew.mx.o
C:\GLEW>pause
Press any key to continue . . . |
Does anyone know what might be causing these multiple definition errors? I notice that the lib directory now has the library files that were supposed to be compiled, and the src directory now has the *.o files that were supposed to be compiled. Is it safe to use these files as they are, or did the compilation fail in such a way that these files are compromised and unusable? In other words, did the compilation really fail, or were those simply warning messages?
Anyway, thanks for reading. Any help will be greatly appreciated.
EDIT:
I see now from further examination that the object and library files compiled correctly. It's the DLL files that failed. I'm really hoping someone has a fix for this.
EDIT 2:
For anyone who might have the same problem in the future, I figured this one out. The commands for compiling the DLL files need to have a -nostdlib tag, like so:
1 2 3
|
gcc -nostdlib -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
gcc -nostdlib -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
|