C code compiled under Linux, there is a case of the TAN function error

Source: Internet
Author: User

Undefined reference to ' tan '

But already contains the head file <math.h>, but still an error, said to be unable to find Tan

The cause of this problem is not very clear, but the online solution is to compile the time with the parameter-lm

There say L means Lib, M represents Math.h,

******************************************************************************************************

Here are some instructions

using the library functions declared in MATH.H is a bit special, the GCC command line must have the-LM option, because the math functions are located in the Libm.so library file (these libraries are usually located in the/lib directory),- The LM option tells the compiler that the mathematical functions used in our program are to be found in this library file. Most of the library functions used in this book (for example, printf) are located in the Libc.so library file, and the library functions in libc.so do not need to be added-LC option at compile time, which of course is not wrong because this option is the default option for GCC.      

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.