Solution to the gcc error: undefined reference to `ilogb’ (C/C++)

The ilogb( ) functions return the exponent of their floating-point argument as a signed integer. If the argument is not normalized, ilogb( ) returns the exponent of its normalized value.

Here’s simple program that uses ilogb()

 

Now, if You use this function and get the following gcc linker error:

undefined reference to `ilogb’

That probably means that You did not tell gcc to link proper library (which contains ilogb function).

You can do this by using -lm switches. The -l means link a library. The m means the math library. You need to link the math library. This is the standard library that has common math functions like sqrt, sin, cos, log, etc. Linking makes these functions available to the main program.

Now You should be able to properly and successfully compile and link Your program.

$ gcc ilogb.c -lm

3 thoughts on “Solution to the gcc error: undefined reference to `ilogb’ (C/C++)

  1. Hello All
    Thanks for checking out my writing website . My name is Noah Wilkinson.
    I have worked since high school in this niche. My interest in writing started at a young age. I wrote poetry as a child and eventually went on to work with my school newspaper.
    This early tryst into journalism eventually led me to academic writing. There is plenty of work for qualified writers. I specialize in research papers , but have the skills to do all types of academic writing.
    Contact me for more information about rates and a price quote. I’m looking forward to helping you.

    Academic Writer – Noah – Funnyhomework Corps

  2. Welcome to my blog ,
    I’m Jen.
    If you’ve ever been too tired and couldn’t finish a research assignment , then you’ve come to the right place. I work with students in all areas of the writing process . I can also write the assignment from start to finish.
    My career as a professional writer started during my school years . After learning that I was very capable in the field of academic writing, I decided to take it up as a career .

    Skilled Academic Writer- Jena Berry- Collegegoalsundaywv Band

  3. Hello, my name is Shyla!

    Im an academic writer and Im going to change your lifes onсe and for all
    Writing has been my passion since early childhood and now I cannot imagine my life without it.
    Most of my books were sold throughout Canada, USA, China and even India. Also Im working with services that help people to save their time.
    People ask me "Please, Shyla, I need your professional help" and I always accept the request,
    cause I know, that only I can solve all their problems!

    Professional Academic Writer – Shyla – Paperhaberdasher Corp

Leave a Reply

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