gpt4 book ai didi

C 错误 - 在 Eclipse IDE 中未定义对 pow 的引用 - 可以在 'main' 函数中使用它,但不能在其他函数中使用。我正在使用 "-lm"编译器标志

转载 作者:太空宇宙 更新时间:2023-11-04 02:56:40 25 4
gpt4 key购买 nike

<分区>

#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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com