MathCode C++ Version 1.4.6,
MathCode F90 Version 1.2.6,
March 22, 2013
When you start MathCode: Remember to close all Mathematica sessions before using MathCode.
Remember to use always the MathCode C++/F90 button available in your Start Menu. (MathCode C++/F90 app group in Windows 8).
This button starts a batch file which sets up correct environment for your C++/F90 compiler, and then starts Mathematica.
Please follow these steps for successful MathCode C++/F90 installation.
MathCode C++ : Required C++ Compiler
MathCode F90 : Required F90 Compiler
If you use Mathematica 8.0 or 9.0 then you must either
If you use Mathematica 6.0 or 7.0 then MathCode already includes a C++ compiler for you..
MathCode already includes a C++ compiler that works with Mathematica 6.0 and 7.0.
However if you have to use another free C++ compiler, Microsoft Visual C++ 2010 Express, you should install it before MathCode installation.
Currently the toolkit is available here
You need to install the Cygwin tool (www.cygwin.com) with at least these 3 packages from category "Devel": gcc4-g++, gcc4-fortran, make. Make sure that the command g++ is directly available from your Cygwin (bash) command line.
MathCode already includes a C++ compiler that works with Mathematica 6.0 and 7.0.
However if you have to use another free C++ compiler, Microsoft Visual C++ 2008 Express, you should install it before Mathcode installation.
Run the program you downloaded or found on a CD and follow the on-screen instructions. The See Choose which C++ compiler you will use, it explains how the setup system determines which C++ compiler you will use.
Use the MathCode C++ button in Start menu in order to start MathCode C++.
The setup system asks you to select a compiler: Currently these compilers are suggested:
(A) MingW32 1.1 (installed together with MathCode)
(B) MingW32 (lookup manually)
(C) Microsoft Visual Studio 2005
(D) Visual C++ 2005 Express
(E) Visual Studio 2008
(F) Visual Studio 2010
(G) Cygwin 1.5.2 (or earlier) gcc
(H) Cygwin 1.7 (or later) gcc
If Microsoft Visual Studio 2005 is installed on your computer, the "Microsoft Visual C++ 2005 Express" is disabled because parallel installation of these tools is not supported.
Mingw32 is free and included in MathCode installation setup automatically. It should be used if you have no Microsoft Visual C++ installed. It is not compatible with Mathematica 8 or 9.
If you have Microsoft Visual C++ installed in your machine it will be detected.
This tool is detected or not detected depending on your specific setup of this tool. It cannot be detected automatically if it has been installed by a different user.
During installation you have to click on the Browse button and browse to any other existing directory on your disk. A batch file should exist in this directory. This match file should set all necessary environment variables for your compiler.
Advanced case: if you want to change the C++ compiler after MathCode C++ installation
Please re-install MathCode C++. The setup will detect a new compiler automatically.
Advanced case: if you want to change the C++ compiler without re-installation.
Execute Configurator.nb in Mathematica. When you choose a compiler name there, it will append compiler definition string to the end of MathCodeConfig.m. These strings are explained in See More on compiler definitions..
Edit StartMathCode.bat and modify the path of the batch file which set up correct environment variables for the new compiler.
If you did not peform these operations correctly you will typically get linking errors during compilation of your C++ code into executable.
Details on manual configuration of C++ compiler
C/C++ compilers on Windows
The GNU compilers
The port of EGCS to Windows used by MathCode is called "MinGW32" which is an acronym for "Minimalist GNU on Win32". Compiled code depends only on libraries that are always provided by Windows, so generated executables can run on any Windows computer. This is not the latest release of MinGW32.
Detailed information about MinGW32 can be found on the following URL:
http://www.mingw.org or search Internet for egcs-1.1.2-mingw32.zip
Specifying Visual C++ as the default compiler
After the installation, you should open Configurator.nb in Mathematica and execute whole notebook. All possible C++ complers will be suggested. When you choose one, MathCode is re-configured for use of your chosen compiler. In this process several MathCode library files are copied and the file MathCodeConfig.m in the main MathCode directory is updated. A new line such as
DefaultCompiler["C++"->"mingw32"]
or
DefaultCompiler["C++"->"vc60"]
is added to it.
For more information about DefaultCompiler[] see See More on compiler definitions..
Using a different unsupported compiler
The precompiled object files distributed are compiled using MingW32 version and Visual C++ versions mentioned above. If you wish to use another compiler, you need to recompile the array library and re-generate code for the standard packages.
Recompiling the array library
Open a command prompt and go to the directory MathCode\lib\lightmat\src
Edit compwin.bat . Select there a compiler that matches best your choice, duplicate the entry for it and adjust the Makefile for it if necessary.
type compwin.bat
This will recompile the array library for your current version. You should also change the default compiler as described above.
Regenerating code for standard packages
Open the notebook lib/stdpackages/src/System.nb in Mathematica. Select "Evaluate Notebook" from the "Kernel" menu. This will regenerate compiled code for this package.
MathCode F90 generates Fortran90 code. In order to compile the Fortran90 code into executable you need a Fortran90 compiler.
Currently MathCode F90 supports automatic compilation with:
You have to install at least one of these compilers. One of them should be chosen during installation.
These Fortran90 compilers: Digital Visual Fortran 6.0 and Intel Visual Fortran 8.0-9.1 are supported by request. Please contact us at mathcode@wolfram.com if you are going to use this compiler.
You need to install the CygWin tool (www.cygwin.com) with at least these 3 packages from category "Devel": gcc4-fortran, gcc4-g++, make. Make sure that the command gfortran is directly available from your CygWin (bash) command line.
You need to install the CygWin tool (www.cygwin.com) with at least these 3 packages from category "Devel": gcc-f77, gcc-g++, make.Then you have to install the g95 tool for CygWin (www.g95.org). Make sure that the command g95 is directly available from your CygWin (bash) command line.
If you are going to use any Intel Fortran compiler please be aware that matching version of Microsoft Visual C++ must be installed before Fortran compiler installation. This C++ version installation must be mentioned in the batch file which sets environment for this Fortran compiler in the command line.
When asked in the MathCode F90 setup dialog asking whether to "set g95 or do not set any compiler", select "do not set any compiler".
In the next dialog select a directory where your BAT file is placed. For Intel Fortran it is typically
"c:\Program Files\Intel\Compiler\Fortran\9.1\IA32\Bin\"
Batch file is typically ifortvars.bat
After installation the last line of MathCodeConfig.m should be changed to
DefaultCompiler["Fortran90"->"ifort808"]
If you use other compilers you should set:
Mathematica 6.0, 7.0, 8.0 and 9.0 are supported. Versions above 9 are not supported.
Windows XP, Windows Vista, Windows7, Windows 8 are supported.
During the installation you will need to specify the location of Mathematica. You should select the Mathematica directory manually. This should be the directory containing the file MathKernel.exe.
The $Machine ID is needed for registration. It is the identity of the machine you want a license for. To find out your $Machine ID, evaluate the following in Mathematica:
$MachineID
You should register to get a key file that will enable you to use the software. If you purchased the software you can register it online at the following URL:
Please do not use this page for demo (trial) licenses !
When you start installation of MathCode you can click the button Register to register your software.
Within two business days you should receive an e-mail with the key file attached. Save the attachment to a file. Remember where you saved it; you will need to select this location during MathCode F90 installation.
You apply for demo(trial) license using online demo request form at
and click on Download Trial version.
When you start installaion of MathCode you should not click the Register button to register your software.
Within two business days you should receive an e-mail with the key file attached. Save the attachment to a file. Remember where you saved it; you will need to select this location during MathCode F90 installation.
Since MathCode relies on many other software products that often change their versions and properties please always download the latest version from the address you get from us together with your key file; currently it is
/products/mathcode/download/download_file.php
Run the program you downloaded and follow the on-screen instructions.
The MathCode F90 runtime library (sheep.lib) is compiled when the first MathCode example runs.
Always use the MathCode button in Start Menu
Remember to always use the MathCode F90 button available in your Start Menu. This button starts a batch file which sets up correct environment for your Fortran 90 compiler, and then starts Mathematica.
If you start Mathematica without using this button, you will typically get errors during compilation phase since the Fortran 90 compiler will not be found.
What are licenses?
For each machine you wish to run MathCode on, you should obtain one key file containing the license. MathCode uses the same $MachineID as Mathematica does to distinguish between machines. A key file is a text file containing a mix of letters and digits. Key files should be put into the Licensing subdirectory of the MathCode installation. The names of the key files do not matter.
When you register for a new MathCode license, you will receive a file that should be put in the Licensing subdirectory of your MathCode installation.
MathCode will use an index file index.m in the Licensing directory to speed up license lookups. If a new license is added, index.m is rebuilt automatically as needed.
If you experience problems with the licensing, you can remove the index.m file, forcing MathCode to rebuild it on the next license check.
For a site installation, users might not have write permissions to the Licensing subdirectory. In this case, the system administrator should rebuild the index file by evaluating the following in Mathematica:
Needs["MathCode`"];
RebuildIndex[ToFileName[{$MCRoot,"Licensing"}]];
If index.m didn't exist, you will se an error message about opening it. This error message can safely be ignored.