Microsoft Visual Studio isn’t for Math
Today I found an interesing quirk in Microsoft Visual Studio .NET 2003, specifically Visual C++.
I was attempting to compile a linux app on my machine that used CMake & VTK. It all went pretty well until I got an error “Unresolved symbol atanh”. I quickly noticed that I wasn’t including math.h and tried again, only to be met with the same error. Figuring that maybe I wasn’t doing it the “Microsoft Way”, I highlighted it and clicked F1 only to find nothing.
After some digging around, I found that atanh, asinh, and acosh are all missing from Visual C++. Instead, they provide a table of derived formulae to compute them. I was amazed. Why would they leave these functions out? If they went through all the trouble to provide a table in their documentation, why not just add the functions, or #define’s? After some research, I finally came across GSL – Gnu Scientific Library, that comes with high precision replacements for alot of math functions, including the missing atanh I needed. A little more digging came up with GnuWIn32, a collection of several libraries compiled for Visual C++, including GSL For Windows.
Now if I can just get “Debugging” priveledges so I can figure out why it still crashes. Seems that pass-by-pointer doesn’t function the same in GCC vs Visual C++.
Update: 5/24/2006 10:30am
As an experiment, I downloaded CodeBlocks with the MinGW compilers. Cmake supports MinGW Makefiles as an output, so I recompiled VTK and my App. I wasn’t able to use the IDE, just ran make from the command line, but now it seems everything is working. It’s faster than Visual Studio, although I’ll freely admit that I am not a VS guru so I may have missed a few optimization flags. But where the VS code returned 0 everywhere and required the GSL library, the MinGW build returns valid values using the built-in atanh function.
Update 9/12/06:
I thought I added this long ago, but Microsoft acknowledges the shortcoming and publishes a workaround here.
[tag:math][tag:gsl][tag:visualc++][tag:microsoft][tag:mingw][tag:codeblocks]

