#include <stdio.h>
#include <stdlib.h>
#include <math.h>

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.

share|improve this question

closed as not a real question by Carl Norum, talonmies, tjameson, Tikhon Jelvis, Soner Gönül May 17 '13 at 6:08

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Your program doesn't even call R_nl. – Carl Norum May 17 '13 at 4:47
    
@CarlNorum but it should not return error – MOHAMED May 17 '13 at 4:48
    
How can it return an error if it's not even called? – Carl Norum May 17 '13 at 4:49
    
@CarlNorum AFAIK, the fact that it calls the function or not shouldn't have anything to do with a compiler error. Besides my program has a lot of extra code where the function is actually code, i have just simplified it like this to get the essence. – vlad-ardelean May 17 '13 at 4:57
    
What compiler error do you get? What you've posted is 100% syntactically correct code. – Carl Norum May 17 '13 at 4:58

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

gcc -lm ./main.c

See man pow

   #include <math.h>

   double pow(double x, double y);
   float powf(float x, float y);
   long double powl(long double x, long double y);

   Link with -lm. //<- Look here
share|improve this answer
    
I eventually did, but in Eclipse it was a little complicated. – vlad-ardelean May 17 '13 at 5:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.