Compiling C program including math functions

Generally you can compile C program as: gcc -Wall <programname.c> and for linking math functions such as pow, you need to specify the -lm option. Note that -lm option should be at the end of the command for Ubuntu11.10. So its better to always put the -lm option at the end of the gcc compilation.


daya@daya-Aspire-4937:~/Desktop/gcc$ gcc -Wall lab2ac.c
/tmp/ccHP22fZ.o: In function `main’:
lab2ac.c:(.text+0x8d): undefined reference to `pow’
collect2: ld returned 1 exit status
daya@daya-Aspire-4937:~/Desktop/gcc$ gcc -Wall lab2ac.c -o lab2ac.o -lm



Tutorial Sheets

Tutorial sheet-1


Why Gcc and Linux System in NEC

C is the great Programming language, and if you know detail about C you can do everything with Computer . Python, Perl, and Java are based on C. The most fabulous part is that the GNU/Linux system is built under C. This year I am teaching C as well as Operating System. Actually , I am breaking the conventional trend in C labs, earlier labs were based on  Turbo-C and on Windows system. However, from this year onward  student would be using GNU/Linux (Ubuntu) and as Gcc Compiler for C Programming.

One of the student asks me about the reason for migration. To be precise and simple,its due to the following reasons.

  1. Linux System offers us the freedom, its due to the liberty of open-source and free software.
  2. Turbo C is very inefficient Compiler than Gcc.
  3. Have opportunity to learn both (Linux System and C Programming) at one time.
  4. To exhilarate student their enthusiasm and passion on FOSS.
  5. To guide and lit  student rather than put them in dark room.
  6. Lastly, to get rid of Piracy, Viruses, Naughty Licenses and much more …………….