Hey everyone.
I'm trying to create & use a static library but kind of stuck at something I can't quite grasp...
I have created library file containing just 2 functions dealing with temperature conversion. I typed the source(.c) file and the headre(.h) file & compiled them to get the library(.a) file.
Now when i use it in a new program I get a LINKER ERROR at the call to the function defined in the library.
[Linker error] undefined reference to `toFahrenheit'
ld returned 1 exit status
I'm not sure where I made the mistake... while writing the source or I'm missing something about linking?
I'm posting my codes.
Source File fore creating the library "temperature.c"
Code:
/*
temperature library file
*/
double c,f,k;
double toCelsius(double x)
{
c = (x-32)*5/9;
return c;
}
double toFahrenheit(double x)
{
f = x*5/9+32;
return f;
}
Header file "temperature.h"
Code:
/*
header file : temperature
*/
extern double toCelsius(double);
extern double toFahrenheit(double);
New Program "Test.c"
Code:
//testing temperature library
#include<stdio.h>
#include "temperature.h"
int main()
{
double c,f;
printf("enter Celsius\t");
scanf("%f",&c);
f = toFahrenheit(c);
printf("Fahrenheit = %d",f);
int ch;
while((ch = getchar()) != '\n' && ch != EOF);
return 0;
}
P.S.
I'm using Dev C++ v4.9.9.2
with GCC v3.4.2 on Windows 7