search instagram arrow-down




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



Leave a Reply
Your email address will not be published. Required fields are marked *

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: