将函数 erf() 和 erfc() 添加到 math.h _ C 基础知识。

发布于 2024-12-08 04:35:23 字数 260 浏览 7 评论 0原文

我正在 WINDOWS 机器上使用 Borland Turbo C++ 编译器,并用 C 编写了一段代码。

我想使用互补误差函数 erfc() 进行我的一次计算。

但是,当我运行代码时,错误是 “链接器错误:模块 filename.c 中未定义符号 _erfc ”

这里的问题是 erfc() 和 erf() 应该包含在 math.h 库中。 然而,这些在我的身上不可用。

谁能告诉我如何将这些功能包含在我的程序中?

谢谢

I am working with the Borland Turbo C++ compiler in a WINDOWS machine, and wrote a piece of code in C.

I want to use the complementary error function erfc() for one of my calculations.

However, when I run the code, the error is
"Linker error: Undefined symbol _erfc in in module filename.c "

The problem here is erfc() and erf() are supposed to be included in the math.h library.
However, these aren't available in mine.

Can anyone please tell me how I can include these functions in my program ?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

望喜 2024-12-15 04:35:23

您可能需要传递一些特殊选项来链接到数学库。

Borland Turbo C++ 也可能不支持 erfc() 函数。

在 C 语言中,1990 年的 ISO C 标准不包含 erfc() 函数。它是由 1999 年标准添加到语言中的。 (我对 C++ 不太确定。)我认为 Borland Turbo++ 已经相当老了。

尝试编写一个调用 sqrt() 的小程序。如果您可以让它工作,但 erfc() 仍然无法识别,那么 Borland 不支持它。

在后一种情况下,要么获取更新的编译器(有许多免费的编译器,无论如何这可能是个好主意),要么找到 erfc() 的开源实现。

It's likely that you need to pass some special option to link to the math library.

It's also possible that Borland Turbo C++ doesn't support the erfc() function.

In C, the 1990 ISO C standard didn't include the erfc() function. It was added to the language by the 1999 standard. (I'm not sure about C++.) I think that Borland Turbo++ is fairly old.

Try writing a small program that calls sqrt(). If you can get that to work, and erfc() is still unrecognized, then Borland doesn't support it.

In the latter case, either get a newer compiler (there are a number of free ones, and that's probably a good idea in any case), or find an open source implementation of erfc().

阳光①夏 2024-12-15 04:35:23

您需要链接到数学库。在 Unix 机器上,这是通过将 -lm 标志传递给链接器来完成的,这意味着“链接到名为 libm 的库”。您可能需要为 Borland 做类似的事情,但我不确定细节。希望这能让您朝着正确的方向前进。

You need to link against the math library. On Unix machines this is done by passing the -lm flag to the linker, which means 'link against a library named libm'. There is probably something similar you need to do for Borland, but I'm not sure on the details. Hopefully this will get you headed in the right direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文