user2214913
user2214913

Reputation: 1511

Going on with no msvcrt.dll

when i compile empty main in mingw i get 27kb exe and 1000 line disassembly, generated exe is referencing kernel32.dll and msvcrt.dll

found somewghere that i can put "-nostdlib -Wl,--exclude-libs,msvcrt.a" options and now generated exe is 3kb and has about 10 lines of assembly

thats fine, also dependency walker-like thing calls no references to anything

i would like to go on with the second form (stripped msvcrt.dll referency) but be able to link to win32.dll-s to make winapi prog (but with no c-lib and stuff)

How to link to winapi dlls now, when i throwed out the msvcrt.dll? need i just add some import libraries for winapi dlls or what?

Upvotes: 0

Views: 1554

Answers (1)

rubenvb
rubenvb

Reputation: 76529

You can just add the libraries you need on the link command line:

gcc -c somefile.c
gcc -o someprogram somefile.o -nostdlib -luser32 -lshlwapi

You might also want to link libgcc statically using -static-libgcc to prevent the libgcc DLL pulling in msvcrt.dll.

Upvotes: 2

Related Questions