Question

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

Was it helpful?

Solution

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().

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top