Compilarea unui singur fișier sursă

Configurare noua (How To)

Situatie

Solutie

Mergem în directorul  /home/student/oso/lab03/simple- gcc unde găsim fișierul simple_hello.c.

student@midgard$ pwd
/home/student/
student@midgard$ cd uso/lab03/simple-gcc
student@midgard$ ls
Makefile  hello.c  simple_hello.c  utils.h
errors.c  help.c   utils.c         warnings.c
student@midgard$ gcc simple_hello.c                                 
student@midgard$ ls
Makefile  errors.c  help.c          utils.c  warnings.c
a.out     hello.c   simple_hello.c  utils.h
student@midgard$ ./a.out
Hello world!


Anterior am folosit comanda gcc căreia i-am dat un singur parametru ca intrare. 
A generat un binar numit a.out. Mai jos putem vedea cum obținem un nume custom 
pentru binarul rezulat în urma comiplării fișierului simple_hello.c. 
student@midgard$ ls
Makefile  errors.c  help.c          utils.c  warnings.c
a.out     hello.c   simple_hello.c  utils.h
student@midgard$ gcc simple_hello.c -o hello                          
student@midgard$ ls                      
Makefile  errors.c  hello.c  simple_hello.c  utils.h
a.out     hello     help.c   utils.c         warnings.c
student@midgard$ ./hello
Hello world!
student@midgard$ pwd
/home/student/uso/lab03/simple-gcc/

Tip solutie

Permanent

Voteaza

(12 din 33 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?