The ‘lm’ option.

It may sometimes happen that when you use commands like sin,cos,pow etc….you get a warning message like ‘undefined reference’ .This may happen even when you have included the header file .This happens because your program has not been linked with the system library properly…
A solution to the situation would be to use the option ‘lm’ when you compile the file.This would fix the problem and the call would be referred to the function definitions in the system’s library.
The syntax would be as follows….
‘gcc -lm filename.c’

Advertisements

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s