<分区>
#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;
}
在 main 中它编译并显示结果(如果我注释掉 R_nl 函数,当然),但它在 R_nl 函数中给我一个错误(与 exp
函数相同)。
使用 Eclipse Juno 进行 c/c++ 开发。
[编辑]:使用 -lm 标志。
[编辑]:使用带有参数的 gcc 编译器 -lm -E -P -v -dD "${plugin_state_location}/specs.c"
来自 Eclipse IDE - linux ubuntu 13.04。
[编辑]:编译器输出,我不知道为什么它看不到我在配置中给它的 -lm
参数....:|
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'
[编辑]:已解决:http://www.eclipse.org/forums/index.php?t=msg&th=68204/
显然有一个特殊的选项页面,您可以在其中指定链接器参数,其中“m”是您要添加的库,它会自动添加选项 -lm
。