Memory Divider X    
 
  Site Map  
  →  Home  
  →  How to Use MDX  
  →  Building MDX  
  →  API Documentation  
  →  Known Issues  
  →  License  
  →  Change Log  
 
  Contact Me  
  →  transmission
.aquitaine
@yahoo.com
 
 
   
  →  Project Home  
  →  Source Code  
  →  Download  
 

Building MDX


MDX = malloc() + free() + Garbage Collection


General Procedure

MDX isn't really built as such. The expected way of "building" it is to include its source files in the compilation of the program using it. It compiles with Microsoft's compiler on Windows, and the GNU compiler on Linux. The download includes a couple of MDX test programs which can be run without any additional coding.

The MDX source files include two headers which have different versions depending on whether the compilation is for Windows or Linux, whether it's for 32 or 64 bits, and whether it's for a big endian or a little endian system. These headers are addr_width.h and mdx.h. Hence the first step in building MDX is to copy the correct versions of these files into the source directory. See the section below on "Getting the Correct Versions of addr_width.h & mdx.h".

Files required to compile MDX itself

addr_width.h
basic_types.h
basic_types_extensions.h
zprintf_etc.h
mdx.cpp
zprintf_etc.c

Apart from addr_width.h, the same source files are used on Windows and Linux.

Headers required to use MDX

#include <stdio.h> // see below for how to avoid this
#include "mdx.h"

Programs using MDX should include the header "mdx.h". The standard C library include <stdio.h> must preceed "mdx.h" for the definition of the FILE structure, since a few MDXPool methods have FILE* parameters. If these methods aren't used, and <stdio.h> isn't included anyway, then a dummy definition of FILE can be substituted for including <stdio.h>.

The soaktest and/or simpletest programs can be built and run to check that everything's working OK.

Files required to compile the simpletest executable

files required to compile MDX itself
mdx.h
simpletest.cpp

If simpletest runs to completion without crashing, or reporting failure of any test, then everthing looks OK.

Files required to compile the soaktest executable

files required to compile MDX itself
mdx.h
soaktest.cpp

If soaktest runs for more than a minute without crashing, then everthing looks OK.

Windows

MDX compiles with Microsoft's Visual Studio. To build simpletest.exe or soaktest.exe make an empty project, add the required files, and compile it. To build make_addr_width.exe make an empty project, add the file make_addr_width.cpp, and compile it.

Pre-Compiled Headers

In order to avoid compiler errors when adding MDX files to an existing project, it may be necessary to disable pre-compiled headers for the MDX files. None of MDX's files use pre-compiled headers.

Unicode

Although the type TCHAR isn't used by MDX's external interface, it is used internally by methods which take a FILE* parameter and output text to it, for example dumpPoolStatus(). These methods are all switched between 16-bit Unicode characters and 8-bit characters in the normal Windows way, depending on the settings of the pre-processor symbols UNICODE and _UNICODE.

Linux

There's no ./configure step. There's also no make install step.

Copy the correct version of mdx.h into the src directory, change to the directory above src, and type make. The makefile will compile and run make_addr_width.cpp to create a correct addr_width.h file. It then builds both the simpletest and the soaktest executables in the bin directory.

Getting the Correct Versions of addr_width.h & mdx.h

The hdr subdirectory of the src directory contains versions of addr_width.h & mdx.h for all situations, sorted by subdirectory. For example, the versions for 64 bit windows on X86 are in the hdr\windows\64bit\little_endian subdirectory.

It's easy enough to tell if a computer's running Windows or Linux(!) To find out if it's a 32 or 64 bit system, and whether it's big or little endian, compile and run the standalone program make_addr_width.cpp. It will output the answers to these questions, and write a correct addr_width.h file in the working directory.

Note that some compilers, such as Microsoft's freebie Visual C++ Express editions, output a 32 bit executable even when running on a 64 bit OS. It's the executable's 64 or 32 bitness that counts. If there's any doubt, then check with make_addr_width.cpp.