c/cpp programming @ Cygwin

to programming @ Cygwin

 

 

 

1. to install Cygwin

 

- to select the mirror websit :

 

http://www.cygwin.cn/pub/

 

- to select the following component:

binutils 
gcc 
gcc-mingw 
gdb
make

 

 

 

2. to verify Cygwin installation is OK? by "Helloworld"

 

 

- to release source code , compile & run it:

 

#include <stdio.h>

int main(void){
	printf("HelloWorld,C!");
}

 

Administrator@g-pc /cygdrive/e/cprogramming/proj/hello
$ gcc hello.c -o hello

Administrator@g-pc /cygdrive/e/cprogramming/proj/hello
$ ls
hello.c  hello.exe

Administrator@g-pc /cygdrive/e/cprogramming/proj/hello
$ ./hello
HelloWorld,C!
Administrator@g-pc /cygdrive/e/cprogramming/proj/hello
$

 

 

- to link 2 source code:

 

* hello1.c:

int main(void){
	print("Hello2,it's Hello1!");
}

 

 

* hello2.c:

#include <stdio.h>

void print(char * s){
	printf("%s",s);
}

 

 

- to compile & run:

 

Administrator@g-pc /cygdrive/e/cprogramming/proj/hello2
$ ls
hello1.c  hello2.c

Administrator@g-pc /cygdrive/e/cprogramming/proj/hello2
$ gcc hello1.c hello2.c -o hello

Administrator@g-pc /cygdrive/e/cprogramming/proj/hello2
$ ls
hello.exe  hello1.c  hello2.c

Administrator@g-pc /cygdrive/e/cprogramming/proj/hello2
$ ./hello
Hello2,it's Hello1!
Administrator@g-pc /cygdrive/e/cprogramming/proj/hello2
$

 

 

 

 

done!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章