I have made some progress. I realized that the symbol information in the VC libraries have a different mangling than mingw's. Here are some examples:
Code:
USER32.dll: file format pei-i386
SYMBOL TABLE:
[ 0](sec 0)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$4
[ 1](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$5
[ 2](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$6
[ 3](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .text
[ 4](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__wsprintfA
[ 5](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _wsprintfA
[ 6](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __IMPORT_DESCRIPTOR_USER32
USER32.dll: file format pei-i386
SYMBOL TABLE:
[ 0](sec 0)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$4
[ 1](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$5
[ 2](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$6
[ 3](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .text
[ 4](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__wsprintfW
[ 5](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _wsprintfW
[ 6](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __IMPORT_DESCRIPTOR_USER32
They do not have the appending number of argument bytes. With mingw's libs, I can do what I want when I say:
Code:
LIBPATH = "C:/Development/Dev/lib"
LIBS = -l gdi32.a -l kernel32.a -l user32.a -l ws2_32.a
Those forward slashes are needed. I am also trying to link to the standard library now, and am encountering some more errors. My makefile, with needed things to link
Code:
LIBPATH = -L"C:/development/dev/lib" \
-L"C:/development/dev/lib/gcc/mingw32/3.4.2"
LIBS = -lgdi32 -lkernel32 -luser32 \
-lws2_32 -lstdc++ -lcrtdll \
-lmingw32 -lgcc
LDFLAGS = --subsystem windows $(LIBPATH) $(LIBS)
test: test.o util.o
$(LD) C:\Development\Dev\lib\crt1.o test.o util.o -o test.exe $(LDFLAGS)
I get many errors from like
Code:
ld C:\Development\Dev\lib\crt1.o test.o util.o -o test.exe --subsystem windows -L"C:/development/dev/lib" -L"C:/development/dev/lib/gcc/mingw32/3.4.2"
-lgdi32 -lkernel32 -luser32 -lws2_32 -lstdc++ -lcrtdll -lmingw32 -lgcc
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0x28):eh_globals.cc: undefined reference to `_imp__TlsAlloc@0'
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0x58):eh_globals.cc: undefined reference to `_imp__GetLastError@0'
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0xe4):eh_globals.cc: undefined reference to `_imp__GetLastError@0'
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0xf5):eh_globals.cc: undefined reference to `_imp__TlsGetValue@4'
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0x107):eh_globals.cc: undefined reference to `_imp__SetLastError@4'
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0x19e):eh_globals.cc: undefined reference to `_imp__GetLastError@0'
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0x1af):eh_globals.cc: undefined reference to `_imp__TlsGetValue@4'
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0x1c1):eh_globals.cc: undefined reference to `_imp__SetLastError@4'
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0x289):eh_globals.cc: undefined reference to `InterlockedIncrement@4'
C:/development/dev/lib/libstdc++.a(eh_globals.o)(.text+0x2a5):eh_globals.cc: undefined reference to `_imp__Sleep@4'
...
C:/development/dev/lib/gcc/mingw32/3.4.2/libgcc.a(gthr-win32.o)(.text+0x178): undefined reference to `_imp__GetLastError@0'
C:/development/dev/lib/gcc/mingw32/3.4.2/libgcc.a(gthr-win32.o)(.text+0x1be): undefined reference to `_imp__CreateSemaphoreA@16'
C:/development/dev/lib/gcc/mingw32/3.4.2/libgcc.a(gthr-win32.o)(.text+0x1de): undefined reference to `InterlockedIncrement@4'
C:/development/dev/lib/gcc/mingw32/3.4.2/libgcc.a(gthr-win32.o)(.text+0x201): undefined reference to `_imp__WaitForSingleObject@8'
C:/development/dev/lib/gcc/mingw32/3.4.2/libgcc.a(gthr-win32.o)(.text+0x210): undefined reference to `InterlockedDecrement@4'
C:/development/dev/lib/gcc/mingw32/3.4.2/libgcc.a(gthr-win32.o)(.text+0x23e): undefined reference to `InterlockedDecrement@4'
C:/development/dev/lib/gcc/mingw32/3.4.2/libgcc.a(gthr-win32.o)(.text+0x262): undefined reference to `_imp__ReleaseSemaphore@12'
C:/development/dev/lib/gcc/mingw32/3.4.2/libgcc.a(_eprintf.o)(.text+0x2e): undefined reference to `fprintf'
C:/development/dev/lib/gcc/mingw32/3.4.2/libgcc.a(_eprintf.o)(.text+0x3e): undefined reference to `fflush'
make: *** [test] Error 1