Markovian Parallax Generate: On digital writing and poetics

Mchain 0.3 – Source Code (C++) Installation and Usage

The Markov Chain Obfuscation Engine (Mchain 0.3)

If you’d like greater functionality and performance than the Mchain Python script, I recommend you get version 0.3 of the program and compile it on your computer. It is run in much the same way, except that you should set your Environment Path to the directory of your  executable file so that it may run from any folder on your computer; that way you can call mchain in your terminal or command prompt in whatever folder your text files are in. It also has an added -r function for a randomized keylength (from zero to k) that varies as the chain is assembled.

Download the C++ Source Folder

The first step, obviously, is to download the code. Click on the link below. If the link is down, contact me and I will send you the file.

NOTE: If you downloaded the file before 7/2/2009, there may have been a bug. The file has been corrected.


> > Download Mchain 0.3 Source Files < <


Compiling the Source Code

Instructions for compiling the program in Linux are included in the README file zipped together with the source code files above. I will partially reproduce them here, too.

If you have Mac OS X, I am not sure how to help you. I will update with instructions when I have tested it out on a Mac.

If you have Windows, see the instructions below. It will help if you would do a Google search for instructions for compiling programs in your operating system, too.

Compiling in Linux (Ubuntu -> Gnome Desktop Environment)

Dependencies (if you’ve compiled something before, you should be fine):

  • gcc – GNU C++ compiler
  • libc6 – GNU Standard C++ library
  • make – GNU make
  • maybe some other build essentials (the compiler errors will often let you now what it needs)


  1. To compile, enter the mchain source file directory in the Terminal and type: make.
  2. Set the permissions of the mchain executable you just compiled to allow it to execute as a program. In a file browser, navigate to the mchain source directory, right-click on the mchain executable (filename: mchain), select Properties, click on the Permissions type, and make sure that the box beside “Allow executing file as a program” is checked.
  3. Move the mchain executable to /usr/bin/ (for Ubuntu and Debian Linux) so that it may run in the terminal from any directory.

That’s it. Now you can go down to the Using Mchain section.

Compiling C++ in Windows

  1. The first step is to download the source code above and extract the files (using Winzip or 7-zip, etc.) into their own directory. If you extract the zip file to the C:/> directory,  an mchain-0.3 folder should be created there automatically. Otherwise, create the folder yourself with that name and extract the files to it.
  2. The second step is to download and install a compiler. My personal choice is MinGW, an open source compiler which is small and user-friendly. You can find the installer file (MinGW-5.1.4.exe) here.
  3. As of May 2009, the installer has a slight bug in it, so before you run MinGW-5.1.4.exe, go to the following link to download a working gcc-g++-3.4.5-20060117-3.tar.gz file for the installer to use. (Try this link if the previous one fails.)  Move the file into your C:\ directory, which will be the same one that the MinGW-5.1.4.exe installation file is in.
  4. Open the installer file and choose the Dowload and Install option. Agree to the license. Make sure you choose the Custom installation option and choose to install everything but the g77, ada and java components — you will not need them. If installation fails the first time you install, try again. It took me a few times.
  5. At this point, you have to set the Environment Path to use your newly installed compiler. While you are there, you may as well also add the Path for the mchain program you will soon be using. This step makes it possible for you to run these programs from any directory on your computer — trust me, this will make things much easier for you. Go to your My Computer icon, right click on it, and select Properties. Now navigate to the Advance tab and click on the Environmental Variable button near the bottom. YOU MUST BE VERY CAREFUL IN HERE. DON’T DELETE OR CHANGE ANYTHING THAT IS ALREADY ENTERED HERE. Very carefully look in the bottom text box for a Path entry. Click on it once and choose to Edit it with the button below. Now go to the end of the existing entry and paste the following text between the arrows at the end of it: –>   ;C:\MinGW\bin;C:\mchain-0.3 <–. AGAIN, DO NOT PASTE OVER IT, BUT AFTER IT. Now you can click OK and OK, etc., to get out. You may want to read the MinGW Getting Started page and the Installation HowTo if you have any trouble with this or the previous steps.
  6. Now that you have installed MinGW, you must enter the command prompt to compile the mchain program with it. If you are unfamiliar with using the Windows command prompt, see this Beginner’s Guide. The cd, cd.. and dir commands should be enough for you to get where you need to be for the purposes of the compiling process.
  7. Type cd.. and hit enter until you reach the base directory, C:\>.
  8. Once there, type cd mchain-0.3 to get to the folder that you extracted the source files into in step one (again, this should be C:\mchain-0.3\)
  9. Now you will enter the command to compile the mchain program. Type mingw32-make. That’s it.
  10. Now you can use the mchain program by typing mchain into the command prompt. Typing only this will return the usage notes for the program, which are the following:

Using the C++ version of Mchain 0.3 (all platforms)

usage: mchain [-v: verbose | -r: random keylength (1->max) | -k: max keylength | -n: rounds of output] input file/s

example: mchain -v -r -k 3 -n 200 input-text1.txt input-text12.txt

The basic instructions in the Mchain 0.2 Script – Download and Usage guide are mostly still correct. Refer to them for tips if you find the brief instructions below inadequate.

To use the compiled mchain program, simply open the terminal or command prompt, go to a folder that has a txt file in it that you would like to run through the mchain program, and type mchain -r -k 3 -n 250 myfile.txt. As the usage notes explain, you can tinker with any of the numbers to achieve different results. You may also run several text files at once, or even type *txt instead of the name of one text file to use all of the text files in that folder at the same time.

An important note on file names: The command line parsing in this program is fairly simple.  If you’re getting file errors for a file you know is good, try renaming it.  Remove any spaces, apostrophes, etc. and try it again.  As for the size of your filenames, the maximum number of characters allowed is 50, including the extension; don’t pass anything larger than that(really, don’t do it).

Please post any problems with compiling the script to this page, or e-mail me at and I will give what help I can.

7 Responses

Subscribe to comments with RSS.

  1. […] 2009 Wow! I’ve been swamped with responses over the past few days regarding the Gnoetry and Mchain 0.3 installation howtos. It’s great to see such a response so soon. There have been a few issues […]

  2. […] Mchain 0.3 – Source Code (C++) Installation and Usage [NEW] Possibly related posts: (automatically generated)Gnoetry: Way Ahead of MeWelcome to the new URLMchain Project his&hers is Off the Ground and Running leave a comment « Howto: Installing Gnoetry 0.2 On Any Platform Updates and Responses to the Gnoetry and Mchain Howtos » […]

  3. […] (source texts: Aldous Huxley’s Brave New World and T.S. Eliot’s East Coker; composed using Mchain) […]

  4. […] 0.3 (C++ program) download and compilation […]

  5. coder said, on March 6, 2013 at 2:13 am

    Thanks for the info and the source code, awesome!

  6. Funny Police Prank said, on May 8, 2013 at 9:14 am

    Hello to all, it’s actually a nice for me to go to see this web page, it consists of important Information.

  7. […] Mchain 0.3 – Source Code (C++) Installation and Usage [NEW] […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: