Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7757869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:12:25+00:00 2026-06-01T13:12:25+00:00

I am programming a c project which must use the pow function defined in

  • 0

I am programming a c project which must use the pow function defined in math.h.
And when I tried to make the project, gcc gave the following link error:
undefined reference to `pow’.

I know the -lm option must be added into my link instruction, but there are still several questions puzzling me.

Q1:When I pass two constants into pow function, link is successful without -lm. Why?

Q2:-lm being at the end or at the start of link instruction makes different results. gcc -lm $(OBJS) -o exbin is wrong, but gcc $(OBJS) -o exbin -lm is correct. Why?

I use ubuntu 11.10 and gcc 4.4.4.

Thanks! Please excuse my pool English.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:12:27+00:00Added an answer on June 1, 2026 at 1:12 pm

    I cannot answer question 1 (that seems odd), but in regards to question 2 the reason gcc -lm $(OBJS) -o exbin does not work is because you must link things in order of useage. This is best explained by example:

    /* File func_a.h */
    /* Declare func_a */
    void func_a();
    
    /* File func_a.c */
    #include "func_a.h"
    void func_a()
    {
        /* do stuff */
    }
    
    /* File func_b.c */
    #include "func_a.h"
    void func_b()
    {
        /* Call func_a */
        func_a();
    }
    

    To properly link func_a and func_b into an executable, you must link them as gcc func_b func_a -o exec because func_b uses func_a. In short, you always want to link your library functions last.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am programming for a big project, so I cooperate with others. To make
I am programming for a big project, so I cooperate with others. To make
I am learning socket programming for use in an upcoming project, and I have
I am programming on a project which I should store the key of the
I recently joined a project which basically uses java as the programming language. I
I'm working on a project which makes heavy use of extension methods to convert
I'm reaching the climax of my final year programming project, which is written in
I have a small project which will use iPad as an information kiosk for
I've Inheritted a large Java Web project which I've got to make some modifications
I do have experience with Ruby on Rails, and am programming a project in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.