将函数 erf() 和 erfc() 添加到 math.h _ C 基础知识。
我正在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能需要传递一些特殊选项来链接到数学库。
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, anderfc()
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()
.您需要链接到数学库。在 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.