jofre
February 24th, 2006, 12:06 PM
Ok lads, this is my first C program. Should be straight forward but gcc is complaining that " undefined reference to `pow' ", and yes I have " #include <math.h> " at the start.
Any ideas why?
Thanks a million, Jofre
Full code:
#include <stdio.h>
#include <math.h>
/* Declaring constants */
const double plank = 6.6261e-34 ; /* Planck's constant [J*s] */
const double c = 2.9979e8 ; /* speed of light [m/s] */
/* Declaring variables */
double density, intensity, wavelenght ;
int main(){
density = ( intensity * pow(wavelenght,4) ) / ( plank * pow(c,2) ) ;
printf("the density is %f", density) ;
}
Full answer form gcc:
$ gcc -g -Wall -o photon_density photon_density.c
photon_density.c: In function ‘main’:
photon_density.c:15: warning: control reaches end of non-void function
/tmp/ccyo0tCe.o: In function `main':
/c_code/photon_density.c:12: undefined reference to `pow'
collect2: ld returned 1 exit status
Any ideas why?
Thanks a million, Jofre
Full code:
#include <stdio.h>
#include <math.h>
/* Declaring constants */
const double plank = 6.6261e-34 ; /* Planck's constant [J*s] */
const double c = 2.9979e8 ; /* speed of light [m/s] */
/* Declaring variables */
double density, intensity, wavelenght ;
int main(){
density = ( intensity * pow(wavelenght,4) ) / ( plank * pow(c,2) ) ;
printf("the density is %f", density) ;
}
Full answer form gcc:
$ gcc -g -Wall -o photon_density photon_density.c
photon_density.c: In function ‘main’:
photon_density.c:15: warning: control reaches end of non-void function
/tmp/ccyo0tCe.o: In function `main':
/c_code/photon_density.c:12: undefined reference to `pow'
collect2: ld returned 1 exit status