Linux Study Notes (3)

Source: Internet
Author: User

GCC compilation FAQ (1): Why does the undefined reference to 'xxxxx' error occur?

First, this is a link error, not a compilation error. That is to say, if this error is the only one, your program source code is correct.
The parameters used during compilation by the compiler are incorrect. You have not specified the library to be used by the linked program. For example, some mathematical functions are used in your program,
In this case, you must specify the program to be linked to the math library in the compilation parameters by adding-lM to the compilation command line. During GCC compilation and calling <math. h>, the parameter-LM is used, where-L is used to identify the library information to be linked:
-LM indicates that the math library libm. A or libm. So or libm. SL needs to be linked.

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.