C error – undefined reference to pow in Eclipse IDE – can use it in 'main' function but not in others. I AM using “-lm” compiler flag [closed]-Collection of common programming errors

#include 
#include 
#include 

const short int Z = 2;

const int parts = 1000;
const double epsilon = 1e-5;

typedef double (*func_n_l_r)(int, double);

double R_nl(int n, int l, double r) {
    return 2 * pow(Z, 1.5) * exp(-r * Z );
}

int main(void) {
    printf("%f",pow(3,2));
    return EXIT_SUCCESS;
}

In main it compiles and displays the results (if I comment out the R_nl function, of course), but it gives me an error in the R_nl function (same with the exp function).

Using Eclipse Juno for c/c++ developments.

[EDIT]: Using -lm flag.

[EDIT]: Using gcc compiler with arguments -lm -E -P -v -dD "${plugin_state_location}/specs.c" from Eclipse IDE – linux ubuntu 13.04.

[EDIT]: Compiler output, and i don’t know why it doesn’t see the -lm argument i gave it in the configurations…. 😐

08:13:52 **** Incremental Build of configuration Debug for project Helium ****
Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is unsupported on this system, attempting to build anyway.
Info: Internal Builder is used for build
gcc -o Helium src/Helium.o 
src/Helium.o: In function `R_nl':
/home/shefuto/Dropbox/pt_sqala/Master 2/sem2/nagy/Helium/Debug/../src/Helium.c:28: undefined reference to `pow'

[EDIT]: SOLVED : http://www.eclipse.org/forums/index.php?t=msg&th=68204/

Apparently there’s a special options page for that, where you can specify linker arguments, where ‘m’ is the library you want to add, and it adds the option -lm automatically.

  1. You need to add -lm flag to compile(linker) command string.

    gcc -lm ./main.c
    

    See man pow

       #include 
    
       double pow(double x, double y);
       float powf(float x, float y);
       long double powl(long double x, long double y);
    
       Link with -lm. //

Originally posted 2013-11-27 12:25:17.