I'm trying to make a Windows GUI program under MinGW on XPSP2. LD gives undefined reference errors to the WinAPI functions I use. Here's my makefile:

Code:
CC = g++
LD = ld

LIBPATH = "C:\Program Files\Microsoft Platform SDK\Lib\"
LIBS    = gdi32.lib, kernel32.lib, user32.lib, ws2_32.lib

CXXFLAGS = -c -Wall
LDFLAGS =  --subsystem windows -e _WinMain@16 -L $(LIBPATH) -l $(LIBS)

all: test

test: test.o util.o
	$(LD) test.o util.o -o test.exe $(LDFLAGS) 

test.o: test.cpp main.h
	$(CC) $(CXXFLAGS) test.cpp main.h

util.o: util.cpp main.h
	$(CC) $(CXXFLAGS) util.cpp main.h 

clean:
	rm -rfv test.exe *o
Ends up resolving to this command, giving these errors

ld test.o util.o -o test.exe --subsystem windows -e _WinMain@16 -L "C:\Program Files\Microsoft Platform SDK\Lib\" -l gdi32.lib
test.o(.text+0x2c):test.cpp: undefined reference to `GetStockObject@4'
test.o(.text+0x62):test.cpp: undefined reference to `LoadIconW@8'
test.o(.text+0x7c):test.cpp: undefined reference to `LoadIconW@8'
test.o(.text+0x96):test.cpp: undefined reference to `LoadCursorW@8'
test.o(.text+0xa7):test.cpp: undefined reference to `RegisterClassExW@4'
test.o(.text+0x122):test.cpp: undefined reference to `CreateWindowExW@48'
test.o(.text+0x149):test.cpp: undefined reference to `ShowWindow@8'
test.o(.text+0x157):test.cpp: undefined reference to `UpdateWindow@4'
test.o(.text+0x17d):test.cpp: undefined reference to `GetMessageW@16'
test.o(.text+0x18f):test.cpp: undefined reference to `TranslateMessage@4'
test.o(.text+0x19d):test.cpp: undefined reference to `DispatchMessageW@4'
test.o(.text+0x1ef):test.cpp: undefined reference to `DestroyWindow@4'
test.o(.text+0x207):test.cpp: undefined reference to `PostQuitMessage@4'
test.o(.text+0x233):test.cpp: undefined reference to `DefWindowProcW@16'
make: *** [test] Error 1