Lab 3 - FL13 - ECE 198 JL - University of Illinois - Engineering Wiki

input file1c input file2c g means c ompile with

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: s how y ou the rec ommended way of doing a c omplete build of an ex ec utable with one c all to gc c : gc c -g -s td= c 99 -W all -W error -o output-ex ec utable -l library 1 [-l library 2] ... input-file1.c [input-file2.c ] ... -g means c ompile with debugging s y mbols . This will allow the debugger to find the C s ourc e line c orres ponding to mac hine c ode (y ou'll learn more about the debugger later) -std= c99 means us e the ANSI 1999 C s tandard. This is the modern dialec t of the C programming language. -W a ll means warn about all pos s ible problems with y our c ode. Pa y a tte ntion to w a rnings the com pile r outputs. -W e rror means fail if there are any warnings . W e rec ommend us ing this option unles s y ou are abs olutely s ure warnings y ou are getting are harmles s . -o output-e x e cuta ble indic ates that the program to be built s hould be c alled output-ex ec utable -l libra ry means link with library at the link ing s tage input-file 1.c input-file 2.c are the inputs files implementing y our program, written in C It is not nec es s ary to give the -o flag when y ou c ompile y our C c ode. If y ou do not s pec ify the name of y our output file us ing the -o flag then the c ompiler gives the output in a file named a .out. Try c ompiling "hello-world.c " without the -o flag to s ee for y ours elf. Gc c will preproc es s , c ompile, as s emble, and link y our program for y ou in one go. And jus t to review, to load and ex ec ute the program if it's in the curre nt w orking dire ctory, we do the following: ./program Linking libraries with C Many times , we write programs that us e func tions from different libraries . For ins tanc e, we have a math library for C, whic h c an be inc luded with a preproc es s or direc tive. The header file to be inc luded is c alled "math.h". This header file provides y ou func tions lik e pow(),s in(),c os (),tan() etc . You c an direc tly us e thes e func tions and henc e reduc e y our work load. Another library is the s tring library , whic h helps y ou ​ rform s tring operations if y ou inc lude the "s tring.h&q...
View Full Document

This document was uploaded on 03/22/2014.

Ask a homework question - tutors are online