0

Dear friends:
i define a function "funtion1", i put the declaration in the "funtion1.h"

#ifndef FUNTION1_H_INCLUDED
#define FUNTION1_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
double funtion1(double ,double );
#endif // FUNTION1_H_INCLUDED

and write the function body in the file "funtion1.c"

The following is my main file, but when i compile it in codeblock, it gives me some error message " undefined reference to funtion1", what is your suggestions.

#include "funtion1.h"
int main()
{
   double aa,bb;
   aa=4.5;
   bb=5.4;

   funtion1(aa,bb);

    return 0;
}
2
Contributors
3
Replies
15
Views
2 Years
Discussion Span
Last Post by mike_2000_17
0

You need to add each source file to the project (through the Codeblock's menus) and build them all together. Actually, it will cause each source file to be compiled individually, and then linked together.

If you want to gain a more complete understanding of this, you can read my tutorial about this.

0

yes, all the file is in the project. but it still gives me the "undefined reference error

0

You also have to make sure that the name and signature matches that of the header file, you have to have exactly this in the source file:

double funtion1(double ,double ) {
  // ... the code
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.