nigels-com / glew

The OpenGL Extension Wrangler Library
Other
2.62k stars 614 forks source link

-nostdlib flag seems to be ruining glewinfo.exe compilation in MinGW #96

Closed ghost closed 4 years ago

ghost commented 8 years ago

Win32, using MinGW+make from MSYS After this command make fails:

gcc -fno-builtin -O2 -Wall -W -Iinclude -fno-builtin -fno-stack-protector -o bin/glewinfo.exe tmp/mingw/default/shared/glewinfo.o -Llib -lglew32 -L/mingw/lib -nostdlib -lopengl32 -lgdi32 -luser32 -lkernel32 tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x33): undefined reference to 'fprintf' tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x54): undefined reference to 'fprintf' tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x5c): undefined reference to 'strlen' (more)

Without -nostdlib it works perfectly. Not sure but it looks like a bug

UPD: the same thing is with visualinfo.exe

nigels-com commented 8 years ago

Confirming this. Seems like there was an intention to prohibit a C library dependency in the GLEW library, but with a side effect of breaking the build of glewinfo and visualinfo.

undisputed-seraphim commented 7 years ago

@randseed How is your Makefile obtained? Is it generated via cmake? It appears that the offending line in cmake is this one. If Clang also produces the error (or if removing that line does not produce any problems with Clang), perhaps we can consider it for removal.

machinewu commented 7 years ago

I also get this error when I build using MinGW in Win10 I found it is errors occurred while building the .exe file using -nostdlib But -nostdlib can not remove while building .dll or .a So, I had add some line to remove "-nostdlib" while building .exe, add follow code after "BIN.LIBS =...": (about at line 158 in file: Makefile)

ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
BIN.LIBS := $(BIN.LIBS:-nostdlib=)
endif

The result code like:

(some code before ... )

# GLEW utility programs

BIN.LIBS = -Llib $(LDFLAGS.DYNAMIC) -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
BIN.LIBS := $(BIN.LIBS:-nostdlib=)
endif

GLEWINFO.BIN       := glewinfo$(BIN.SUFFIX)
GLEWINFO.BIN.SRC   := src/glewinfo.c
GLEWINFO.BIN.OBJ   := $(addprefix tmp/$(SYSTEM)/default/shared/,$(notdir $(GLEWINFO.BIN.SRC)))
GLEWINFO.BIN.OBJ   := $(GLEWINFO.BIN.OBJ:.c=.o)

(some code after ... )
Alvaro-Santos commented 7 years ago

@machinewu You're an angel

nigels-com commented 5 years ago

Todo: Do some fresh testing on Windows.

nigels-com commented 4 years ago

Fixed now, I think.