Question

I'm working on a C++ app which uses the LLVM JIT backend to compile code on the fly. In this JIT-compiled code, I want to be able to call all of the math.h functions, but currently it only works for some of them, i.e. fabs is present but fabsf is not.

It seems like the symbol for fabs is in the msvsrt.lib runtime library, but not fabsf, even though they're both declared in my system's math.h. Am I linking to the wrong runtime library? Or do I need to get an 'extended' math dll from elsewhere and link to that as well?

  • Platform: Windows 7, Visual Studio Express 2012
  • In properties, C/C++ > Code Generation > Runtime library = Multi-threaded DLL (/MD)
Was it helpful?

Solution

It looks like in some cases, math.h defines fabsf like this (taken from math.h included with MSVC2010 express)

#define fabsf(x)    ((float)fabs((double)(x)))

Your runtime library probably is implemented this way, meaning that fabsf does not exist at all, and "normal" fabsf is replaced by the C-preprocessor by a call to _fabs().

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