muParser - a fast math parser library
Version 2.1.0
Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads
My home page
My home
page
class documentation
muParser
API-doc

Open source initiative logo

Valid XHTML 1.0 Transitional

CSS ist valide!

Build instructions

Building on win32

muParser supports various win32 command-line compilers:
  • Mingw
  • Borland C++
  • Watcom
  • Microsoft CL
In order to compile muParser from makefiles, open a command prompt then move to the muParser/build directory and type:
  • mingw32-make -fmakefile.mingw for mingw
  • nmake -fmakefile.vc for msvc
  • make -fmakefile.bcc for borland
  • wmake -fmakefile.wat for watcom
All makefiles support the following options:
  # Set to 1 to build debug version [0,1]
  #   0 - Release
  #   1 - Debug
  DEBUG = 0

  # Set to 1 to build shared (DLL) version [0,1]
  #   0 - Static
  #   1 - DLL
  SHARED = 0

  # Set to 1 to compile samples [0,1]
  SAMPLES = 1
The muParser library is created in the 'lib' folder and the sample binaries are created in samples\example1 or samples\example2. (You may need to copy the dll into the example2 directory in order to run it.)
warning samples\example1 can be compiled *only* when building muParser as a STATIC library (SHARED=0).
samples\example2 can be compiled *only* when building muParser as a SHARED library (SHARED=1).

Building on BSD/Linux

muParser can be installed just extracting the sources somewhere and then, from a terminal, typing:
 cd [path to muParser]
 ./configure [--enable-shared=yes/no] [--enable-samples=yes/no]
             [--enable-debug=yes/no]
 make
 [sudo*] make install
* = this command must be executed with root permissions and thus you have to use 'sudo' or just 'su' to gain root access. Note that installation is not strictly required.

The "make" step will create the muParser library in 'lib' and the sample binary in samples/example1. The samples/example2 is win32-specific and thus won't be built.

Other miscellaneous info Unix-specific

If you don't like to have your muParser folder filled by temporary files created by GCC, then you can do the following:
  mkdir mybuild && cd mybuild && ../configure && make
to put all object files in the "mybuild" directory. If you want to use muParser library in your programs, you can use the pkg-config program (this works only if muParser was installed with 'make install' !). The commands:
  • pkg-config muparser --cflags
  • pkg-config muparser --libs
will return all useful info you need to build your programs against muParser !

Including the source code directly

Sometimes including the library sources directly into an application is the easiest possibility to avoid linker conflicts originating from different versions of the runtime libraries used by the parser and your project. In order to use the parser simply include the following files into your project:

muParser.cpp
muParserBase.cpp
muParserBytecode.cpp
muParserCallback.cpp
muParserError.cpp
muParserTokenReader.cpp

And make sure the following files can be found in your projects include path:

muParser.h
muParserBase.h
muParserBytecode.h
muParserCallback.h
muParserDef.h
muParserError.h
muParserFixes.h
muParserStack.h
muParserToken.h
muParserTokenReader.h

The parser class and all related classes reside in the namespace mu (MathUtils). So make sure to either add a using
using namespace mu;
to your files or reference all classes with their complete name.

Compiler switches

If you use muParser by compiling your own version or including the source code directly you can use a set of preprocessor definitions in order to customize its behaviour. The following definitions are located in the file muParserDef.h:
#define MUP_BASETYPE double
The macro MUP_BASETYPE defines the underlying datatype used by muParser. This can be any floating point value type (float,double or long double). The macro defaults to double. Modify this value if you need higher precision or want to use muParser seemless with client code that is using float as its data type.
#define MUP_MATH_EXCEPTIONS
When this option is set an exception is generated in case of a division by zero. By default this option is not set and division by zero is silently signalled with +/-inf.
#define MUP_USE_OPENMP
If this option is set OpenMP is used for parallelization of the calculations performed in the bulk mode. By default this option is not set. According to my observations OpenMP does not bring any benefit when used with fully optimized code as produced by C++/VS2008 under Windows. It does however bring a significant performance increase when using the muParser dll from C#. I don't really have a good explanation for this but my best guess is that C# has a significant overhead when muParser is using callback functions implemented as C# delegates. OpenMP can spread this overhead amongst multiple cores whilst it can't improve the C++ code since it is already highly optimized and the execution speed is finally limited by the memory bandwidth.
#define MUP_STRING_TYPE std::wstring
This definition determines the string type used by muParser. This can either be std::string or std::wstring. This definition shouldn't be set directly. It is defined to std::wstring if there is a preprocessor macro _UNICODE present. (This definition is set by VS2008 accoring to the project settings.)

Where to ask for help

If you find problems with either compilation, installation or usage of muParser, then you can ask in the muParser forum at:
For more info about muParser, visit:
© 2005-2011 Ingo Berg ^ TOP