Snippets‎ > ‎C Examples‎ > ‎

Hello World C Example for Cygwin

BY MARKUS SPRUNCK


You need a running installation of CYGWIN. If you haven't installed one, you may read Installing and Updating Cygwin for a detailed description.

// Snippet #1 'hello.c'
#include<stdio.h>

main()
{
    printf("Hello World!");
}
// Snippet #2 'makefile'This is a make file for gcc version 4.5.3 and target i686-pc-cygwin. 
TARGET    = hello.exe
OBJECT_01 = hello.o
SOURCE_01 = hello.c

$(TARGET): $(OBJECT_01)
    gcc -o $(TARGET) $(OBJECT_01) 


$(OBJECT_01) : $(SOURCE_01)
    gcc -c $(SOURCE_01) -o $(OBJECT_01)


all : $(TARGET)
   

clean :
    -rm $(TARGET) $(OBJS)

Expected Result

Call make in the bash shell and don't forget to execute hello.exe with the current path (./hello.exe).


The file hello.exe has a size of 21.854 Bytes.

Links

Sponsored Link