How to link the main.c file with an external file in eclipse? and Do you know? how to use math.h library on Eclipse?

We usually use “extern” keyword in c to connect external files with the main.c file and if the main.c is not linked with an external file, the Eclipse will show error like “undefined reference to “

In order to explain, how to link main.c with an external file a project called signalmean.c is used and an external file(wave.c) is used.

The above picture show’s a signalmean.c  which we consider as a  main.c file  and wave.c is an external file

(i) first create an external file (wave.c) by going to project explorer (workspace) and select the project from the list where you would like to add external file then right-click on that project file  >new >file

(ii) the main file(signalmean.c) can be linked with external file by right click on the signalmean project folder> properties>c/c++ build>settings>miscellaneous>add>workspace>and select the external file.

Do you know? how to use math.h library on Eclipse?

Have you ever used math.h library on Eclipse? What have you experienced? What kind of error did you get? when you used first-time math.h on Eclipse.

But wait! I will tell you what happened, when I first used math.h on Eclipse, as usual, when I included the header file # include <math.h> and used functions like sqrt() and pow() in the project

Now, when I build the project, I got [error] like “ undefined reference to pow() “ and  “undefined reference to sqrt()” despite including math.h

So, without wasting any time let’s move on and talk about how to overcome [error]  “ undefined reference to sqrt() and pow()? Let me help you with that,

  1. Go to your project explorer(workspace)
  2. Select the project
  3. Then right-click on that project–>properties–>c/c++ build –>settings–>libraries–>and click on green  + symbol
  4. Then enter m
  5. Apply and close

BOOM!  The error has gone


Hi, i am Mohammed Anees

Leave a Reply

Your email address will not be published.