Ubuntu 11.04 and MATLAB x64 C, C++ and Fortran libraries
MatLab requires the use of libraries (think translation dictionaries) to run code that is outside of it’s native realm (a hybrid C).
The most common of computing languages are those of C and Fortran (an old machine code).
The problem is that old code runs typically on 32 bit (a way of addressing memory), whereas most modern operating systems are now running 64 bit.
If you run a 64 bit Linux distro then you cannot run 32 bit MATLAB and you will be forced to install and run x64 MATLAB (there are some work around for Windows).
Added complication comes from the fact that you need 32 and 64 bit libraries to run some code. This is due to some of the 64 bit compilers being unable to effectively mimic a 32 bit environment.
The best analogy I can think of is trying to read French in English knowing no French and having only an Ancient Latin dictionary as a reference. But if you then have an Ancient French to Ancient Latin dictionary as well you can have a fair stab at comprehension, even if it’s through Ancient French to Latin to English.
This whole process is further complicated, as by default Ubuntu will not let you have 2 versions of the same library. By installing the 32 bit library you replace the 64 bit.
In Fedora it is assumed that whilst the OS is 64 bit you’ll want to use 32 bit libraries. As a result, Fedora has both
Ubuntu does not. Ubuntu gives you
/usr/lib. What we need to do is install all the 64 bit libraries which is automatically linked, then create a
/usr/lib32, install the 32 bit libraries and then symbolically link the 32 bit libraries into
/usr/lib. However, we first need to install a repository that gives us the facility to run more than one library, so that the 32 bit links don’t overwrite the 64 bit links.
Go to System > Administration > Symantic Package Manager.
Using the Quick Filter install:
- gfortran-4.5 (or newer)
Apply these updates and close.
Open a Terminal window. Now we need to install a few other things
sudo apt-get install gcj
sudo apt-get install autoconf
sudo apt-get install automake
Intel Compiler Suite
sudo apt-get install gcc
sudo apt-get install build-essential
sudo apt-get install libc6-dev
sudo apt-get install ia32-libs
sudo apt-get install g++-multilib
sudo apt-get install libc6-dev-i386
sudo apt-get install alien
sudo apt-get install rpm
sudo apt-get install libstdc++5
sudo apt-get install libstdc++5-3.3-dev
Now everything should be installed. Now we need to install the x32 without overwriting the x64 in
/usr/lib. So we need to manually download the library, unpack them and link manually.
So, download the 32 library (link) (Update: latest version is 4.5, give it a Google)
dpkg --extract libstdc++5_3.3.6-18_i386.deb ./
Change the version number if you’ve downloaded a different version
Note that a
/usr folder has been created wherever you downloaded the folder to. We need to now copy this file to
cp libstdc++.so.5.0.7 /usr/lib32
Now link the x32 library to your system
ln -s libstdc++.so.5.0.7 libstdc++.so.5
Update your system:
sudo apt-get update
Now MATLAB should be working with all the required libraries in 32 and 64 bit.
To further get DeerAnalysis working requires 2 more lines of code in terminal:
cd [path to DeerAnalysis]
gfortran -o ftikreg_r_new.out ftikreg_r_new.f
gfortran -o ftikreg_r_old.out ftikreg_r_old.f
Thanks to Gunnar Jescke