gcc portable for windows revisited
This method makes a gcc folder (with less bloat) that I can zip and move around and compile from the windows/dos command line (gcc version 3.4.5)
It does not guarantee full compatibility or every library, but if you run into errors you can always go back to the full mingw files and copy something over (or just install mingw).
Download mingw gcc but don't install, about 5 tar.gz files
Extract them all into directories
Now you just need the essentials (which are scattered about), copy them into a new folder called gcc
gcc.exe cpp.exe
cc1.exe
copy the "include" folder from the "dev" tar.gz (i.e. search for stdio.h) into your gcc folder
We can test our progress using just the compiler (our local include directory)
gcc.exe -c helloworld.c -Iinclude
gcc.exe -o helloworld.c.exe helloworld.c -Iinclude -Llib
you should begin receiving helpful errors like "cannot exec as" Which means we need to find as.exe (from binutils\bin) and copy it into our gcc directory (yes, with gcc.exe)
as.exe cr2t.o crtbegin.o
gcc.exe -o -v hello.c.exe hello.c -Iinclude -Llib -Wall -ansi -v (all warnings and ansi too! VERBOSE shows us what ld.exe can't find)
Now we start to get the fun warnings, like "cannot find -lgcc"
which really means the object, libgcc.a Which we dutifully copy into our new gcc\lib folder
WINDOWS 32 depending on what functions/libraries you're using you may need:
gcc.exe -o -v hello.c.exe hello.c -Iinclude -Llib -Llib\win32 -Wall -ansi -v
to resolve errors for -luser32 (libuser32.a)
create a subfolder inside of gcc\include called win32
copy all items from the w32\include into the win32 folder (needed if you are creating and compiling windows 32 programs with gcc, e.g. winsock.h)
create a subfolder inside of gcc\lib called win32
copy all items from the w32\lib into the win32 folder (needed if you are creating and compiling windows 32 programs with gcc, e.g. libwsock32.a )
batch file to speed things up:
gcc.exe -o %1.exe %1 -Iinclude -Llib -Llib\win32 -Wall -ansi
(replace %1 with the name of a helloworld.c file )