Popular IDE's and GCC Compiler:



List of freeware IDE's:

notepad++ Syntax Highlighting Editor



List of free Compilers:

www.cygwin.com

Visual Studio Community

MinGW Developer Studio




Introduction to GCC


To compile a program:

gcc program.c

Result: a.exe (Windows) or a.out (Linux)


Compiling a program with a different executable name:

gcc program.c -o program

Result: program.exe (Windows) or program.out (Linux)


Generate all warnings (Suspicious code):

gcc -Wall program.c


Turn on Optimizations:

gcc -O program.c


Compile a C-program that uses the math library:

gcc program.c -lm


Program with symbolic information for the debugger:

gcc -g program.c


Project (two files) compilation

How to compile a system consisting of several program files. One of them must have main() function

mainprog.c and funclib.c will be used together


Compiling to object files

gcc -c mainprog.c funclib.c


After that, linking all the object files together in one executable:

gcc mainprog.o funclib.o -o myprog

The Result is an executable file with the name myprog

Support file extensions

.c - C language files

.i - preprocessed C source code

.s - assembly language source code

.o - compiled object code

.a - statically linked compiled library code

.so - shared Object code

Header files and library directories


for MinGW:

C:\MinGW\include

C:\MinGW\lib\gcc\mingw32\4.9.3\include

C:\MinGW\lib

C:\MinGW\lib\gcc\mingw32\4.9.3


For Linux:

/usr/include

/lib

GCC options

Set name for executable file

-o outputexecutable


Compile and assemble (object file creation)

-c


Compile only and prepare Assembly code without assembling

-S


Preprocess only, create .i file

-E


All gcc options print

--help


get current version of gcc

--version


print all warnings

-Wall


Optimization (n= 0, 1, 2, 3)

-On


Compile with information for gdb

-g


Add include directory

-I dir


Add library directory

-L dir


???

-v


Set standard c89

-ansii


Link using static libraries

-static

Using Assembler as:

In development...

Using the Debugger gdb

In development...

Using lint

In development...