john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

gcc tutorial

gcc = gnu c compiler

gcc -c foobar.c

will compile foobar.c into an object (note that gcc can detect the .c extension and compile accordingly)

gcc -o foobar.exe foo.o bar.o

to link and load those objects together into an executable

winwithresource -i resourcescript.rc -o foo.o

gcc.exe -o %1.exe %1 -lws2_32 -lwsock32 -Iinclude -Llib

my batch file command to go straight from source code to executable -also loads two static libraries (from bloodshed devcpp for winsock) -also uses switches for parameters for Include and Lib directories with included header files and Lib files...

how to setup gcc on windows -the easiest way to set up a minimal slightly customized portable gcc is to download the necessary files from the mingw sourceforge project

you will need the core package, gcc.exe cc1.exe

the binutils package as.exe ld.exe

gcc -c filename.c -Iinclude

will compile and create a filename.o (as long as you have all the headers in directory "include")


  • « gcc3 tutorial
  • object oriented programming tips »

Published

Feb 6, 2010

Category

c-programming-guides

~154 words

Tags

  • c-programming-guides 25
  • gcc 9
  • tutorial 6