Size: 16613
Comment: Add my glpkcc.glxmex
|
Size: 13473
Comment: Remove GLPKMEX instructions to a github repo
|
Deletions are marked like this. | Additions are marked like this. |
Line 107: | Line 107: |
== Installing GLPKMEX == This is completely optionnal but this guide help you to install `glpkmex` which adds the `glpk` function to MATLAB that basically calls a C program called GLPK (GNU Linear Programming Kit). This guide will assume you have a 32 bit installation of MATLAB on a 64 bits system (which is the case with the student version of MATLAB). However, each time I do something specific for 32 bit, I tell it so you can adjust it if you are not in that case. Anyway, I think nothing has to be done for 64 bit MATLAB users since there is already a `glpk.mexa64` in the GLPKMEX folder (whe are building `glpk.mexglx`) so they will only need to do the ''Set Path...'' thing. Even if you have a 32 bit MATLAB, you maybe won't have to recompile it. Try to place [[https://help.ubuntu.com/community/MATLAB?action=AttachFile&do=get&target=glpkcc.mexglx|my compiled `glpk.mexglx`]] in your GLPKMEX folder and run `glpktest1` and `glpktest2` inside it to see if it works. If it does not, try to install GLPK and retry. If it still doesn't work, you will have to follow all the steps below. (Note that you still have to do the ''Set Path...'' thing in any case). === Installing GLPK === First, you will need to install GLPK. The version 4.40 works fine with GLPKMEX-2.11 with the version 4.49 doesn't work with it. I have not checked the version between so just go with 4.40. Get the source [[http://ftp.gnu.org/gnu/glpk/|here]], unpack it with the ''Archive Manager'' and then open a terminal and go in the folder where you un packed it (for example, if it is in download, run `cd ~/Downloads/glpk-4.40`) Then run {{{ make clean ./configure --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" make CFLAGS+=-fPIC make check make prefix=/usr/local install }}} The `CFLAGS+=-fPIC` is needed if you plan to install it in 64 bits with gmp (if you're not sure, just use it). The ` --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"` is needed if you are running MATLAB 32 bits on a 64 bits machine. === Installing GLPKMEX === Download the version 2.11 of GLPKMEX [[http://sourceforge.net/projects/glpkmex/|here]] and unpack it somewhere. Open MATLAB and navigate to the folder of GLPKMEX and run {{{ mex CXXFLAGS='$CXXFLAGS -m32' -I/usr/local/include glpkcc.cpp /usr/local/lib/libglpk.a }}} Only use `CXXFLAGS='$CXXFLAGS -m32'` if you have a 32 bits MATLAB. I don't understand why it needs this option since `mex` is run inside MATLAB so it should now that it is in 32 bits however it is needed for me. You can test your installation by running `glpktest1` and `glpktest2`. The last thing you need to do is to make `glpk` accessible from anywere. Indeed, you can only run a MATLAB script in MATLAB if it is in your current directory. You will need root access for this so close matlab and run it with `sudo` (`sudo matlab` or `sudo matlab -glnx86` to force it to use 32 bits). Now click on ''File'' then ''Set Path...'' and add the directory where `glpk.m` is located (that's where you unpacked GLPKMEX). Don't forget to save and quit MATLAB, you're done ! |
Parent page: Programming Applications
Introduction
MATLAB® is a high-level language and interactive environment that enables you to perform computationally intensive tasks faster than with traditional programming languages such as C, C++, and Fortran.
You can use MATLAB in a wide range of applications, including signal and image processing, communications, control design, test and measurement, financial modeling and analysis, and computational biology. Add-on toolboxes (collections of special-purpose MATLAB functions, available separately) extend the MATLAB environment to solve particular classes of problems in these application areas.
MATLAB provides a number of features for documenting and sharing your work. You can integrate your MATLAB code with other languages and applications, and distribute your MATLAB algorithms and applications.
MATLAB R2012a
Important Note Regarding Ubuntu 12.04
MATLAB R2012a was released on March 1, 2012. Please note that this is prior to the release of Ubuntu 12.04. Consequently Ubuntu 12.04 is not a supported operating system for MATLAB R2012a as it can be seen in the MATLAB Roadmap.
MATLAB R2012a users are strongly encouraged to install R2012a on Ubuntu 10.04 LTS or Ubuntu 10.10 for best results. Help for the installation of MATLAB R2012a on Ubuntu 12.04 will however be given through this tutorial.
Important Note Regarding Student version
Unfortunately, 32-bit is the only version available to students.
If you have a 64-bit system, you will have some trouble but it is normally possible to go through each of them and the details are in the Troubleshooting section.
However, the following section helps you be a length ahead of these problem.
How To Install 32-bit MATLAB on 64-bit system
If you have a 64-bit system, you can still install 32-bit version of MATLAB. However, you will need to install the "ia32-libs" package before the installation.
Once it is installed, run the installer with the -glnx86 argument to force it to use 32-bit
sudo /media/MATHWORKS_R2012A/install -glnx86 -v
Though for R2012a it is not necessary anymore. If you don't run it with the -glnx86 argument, MATLAB will just say
Could not find JRE for glnxa64. Trying glnx86.
at the start of the installation. And it will use 32-bit.
Then, just follow the instructions of the Installation Instructions section.
After the installation, you will need to run MATLAB with the -glnx86 argument to force it to use 32-bit
matlab -glnx86
See the Troubleshooting section for more details on this.
Installation Instructions
You will need superuser privileges. The assumption is that MATLAB install files are located at /media/MATHWORKS_R2012a in your filesystem.
See the Troubleshooting section if you get into trouble during the installation.
1. Run the MATLAB installer with the following Terminal command (The -v argument is for the install script to be verbose which means, it is more likely to warn you if something weird happens):
sudo /media/MATHWORKS_R2012A/install -v
If it complains about java, try installing install ''OpenJDK Java 6'' package because MATLAB is not compliant with Java 7.
2. When prompted to 'Choose installation type' you should select custom. This will allow you to create symbolic links to MATLAB in /usr/local/bin.
3. When prompted to 'Specify installation folder' it is recommended that you use the default folder /usr/local/MATLAB/R2012a (or the default /usr/local/MATLAB/R2012a_student if you have a student version).
If you have a student version, the default folder will be /usr/local/MATLAB/R2012a_Student.
4. When given the option to 'Create symbolick links to MATLAB scripts in:' it is recommended that you check the box and use the supplied path /usr/local/bin.
5. You can check that your installation work by executing the following command
matlab
See the Troubleshooting section if you get errors.
Create A MATLAB Launcher
1. Get an icon:
sudo wget http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -O /usr/share/icons/matlab.png
2. Get the launcher file:
sudo wget 'https://help.ubuntu.com/community/MATLAB?action=AttachFile&do=get&target=matlab-r2012a.desktop' -O /usr/share/applications/matlab.desktop
If you have the student version of MATLAB (or simply the 32 bit version) on a 64 bit system, you will need to modify this file. Run
gksudo gedit /usr/share/applications/matlab.desktop
Then uncomment #Exec=matlab -arch=glnx86 -desktop and comment Exec=matlab -desktop (by adding or removing the # character).
If you get two MATLAB launcher icons in your Unity laucher, try uncommenting the following line in /usr/share/applications/matlab.desktop:
StartupWMClass=com-mathworks-util-PostVMInit
If your launcher does not work, see the Troubleshooting section.
MEX functions
Warning
The content of this section has been written for R2011a with Ubuntu 10.04 and 10.10. It may vary a lot if you are using the R2012a with Ubuntu 12.04.
If you try to compile MEX functions you may see a message like the following:
Warning: You are using gcc version "4.4.4-14ubuntu5)". The version currently supported with MEX is "4.3.4". For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release/
Note this is a warning - the MEX function will still compile.
The following instructions will setup gcc 4.3 and make it the default compiler for MATLAB:
1. Install The GNU Compiler Collection 4.3 and The GNU Standard C++ Library
2. Make a MATLAB specific bin directory for gcc symlink.
mkdir ~/.matlab/bin
3. Symlink gcc to gcc-4.3 via user MATLAB specific bin directory.
ln -s /usr/bin/gcc-4.3 ~/.matlab/bin/gcc
4. Add MATLAB specific bin directory to the front of your system $PATH within your local startup.m file.
printf "setenv('PATH',sprintf('/home/%%s/.matlab/bin:%%s',getenv('USER'),getenv('PATH')));\n" >> ~/Documents/MATLAB/startup.m
Steps 3 and 4 above may not work for at least one instance of a user trying to compile using MEX in MATLAB R2011a running on Ubuntu 10.10. An alternative is to do the following:
- 3a. At the MATLAB Command Window prompt, type:
mex -setup
and choose option 2 which says:
2: /usr/local/MATLAB/R2011a/bin/mexopts.sh : Template Options file for building MEX-files via the system ANSI compiler
This will copy to your home directory a local copy of the file mexopts.sh.
- 4a. Then edit this local file:
sudo gedit ~/.matlab/R2011a/mexopts.sh
and replace all instances of CC='gcc' to CC='gcc-4.3', CXX='g++' to CXX='g++-4.3', and FC='gfortran' to FC='gfortran-4.3'. Save and exit. The next time you run MEX in MATLAB to compile it will work properly.
For more ideas, try this thread or this one.
Troubleshooting
No MATLAB bin directory for glnxa64
If MATLAB tells you
--------------------------------------------------------------------------- Warning: Cannot locate Java Runtime Environment (JRE) . . . 1. Either a correct JRE was not available for redistribution when this release was shipped, in which case you should refer to the Release Notes for additional information about how to get it. 2. Or you have tried to use the MATLAB_JAVA environment variable to specify an alternate JRE, but MATLAB cannot find it. Please run 'matlab -n' to determine what value you are using for MATLAB_JAVA and fix accordingly. --------------------------------------------------------------------------- matlab: No MATLAB bin directory for this machine architecture. ARCH = glnxa64
when you launch it, you will need to force it to use glnx86.
Solution for the command line (CLI) launch
To do so, run
matlab -glnx86
If you like launching MATLAB from the command line, you will maybe find it inconvenient to write -glnx86 each time you need to launch it. You can then add it in your ~/.bashrc (at the end if you hesitate where to put it)
alias matlab='matlab -glnx86'
Solution for the graphical (GUI) launch
You will need to add the -glnx86 argument to matlab in the exec line of your file /usr/share/applications/matlab.desktop If you have followed the 'Create a MATLAB Launcher' section, you can just comment the line with the argument -glnx86 and uncomment the next line as explained in the file.
libc.so.6 not found
If you have Ubuntu 12.04, you will probably get
/usr/local/bin/matlab: 1: /usr/local/MATLAB/R2012a_Student/bin/util/oscheck.sh: /lib64/libc.so.6: not found
or
/usr/local/bin/matlab: 1: /usr/local/MATLAB/R2012a_Student/bin/util/oscheck.sh: /lib/libc.so.6: not found
when you launch MATLAB. R2012a is aimed at Ubuntu 10.04 for which libc.so.6 was located in /lib for 32 bits and in /lib64 for 64 bits. It are now both located in a different subdirectory of /lib. To help MATLAB find it, just make a symbolic link
For 64 bits users (that got the first error):
sudo ln -s /lib/x86_64-linux-gnu/libc.so.6 /lib64/libc.so.6
For 32 bits users (that got the second error):
sudo ln -s /lib/i386-linux-gnu/libc.so.6 /lib/libc.so.6
For 64 bits users with the Student version of MATLAB, it is apparently advised by MathWorks to do
sudo ln -s /lib/x86_64-linux-gnu/libc.so.6 /lib/libc.so.6
but the thread mentioned above is for R2011a so I don't know whether it is still accurate or not.
libXmu.so.6 not found
If you get
/usr/local/MATLAB/R2012a_Student/bin/glnx86/MATLAB: error while loading shared libraries: libXmu.so.6: cannot open shared object file: No such file or directory
just install the "ia32-libs" package.
Java problems
If you get
exec: 2433: /tmp/install.dir.880/Linux/resource/jre/bin/java: not found
or
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class java.awt.Component at java.lang.Class.forName0(Native Method) ... Finished
during the installation or MATLAB fails at startup after the installation is complete, maybe you are trying to install a 32-bit version of MATLAB on a 64-bit system because you have the student version or for whatever reason (see Important Note Regarding Student version and How To Install 32-bit MATLAB on 64-bit system).
In order to do that, you need to install the "ia32-libs" package.
Source
http://www.mathworks.nl/support/solutions/en/data/1-C7174M/index.html?product=PB&solution=1-C7174M
Matlab executable not in path
If the matlab executable is not in your PATH, the matlab.desktop file needs to be edited. Replace
matlab -desktop
with the full executable path (default: /usr/local/MATLAB/R2012a/bin/matlab)
/usr/local/MATLAB/R2012a/bin/matlab -desktop
or you can add the Matlab bin folder in your path at login adding this line in your ~/.profile
PATH=$PATH:/usr/local/MATLAB/R2012a/bin
Previous Versions
External Links
Compatibility information:
< http://www.mathworks.nl/support/sysreq/sv-r2012a/linux.html > - System Requirements - Release 2012a
< http://www.mathworks.com/support/compilers/R2012a/glnxa64.html > - Supported and Compatible Compilers – Release 2012a - Linux
For more information about MATLAB see the following links
< http://www.mathworks.com/ > - MathWorks - MATLAB and Simulink for Technical Computing.
< http://www.mathworks.com/products/matlab/ > - MATLAB - The Language Of Technical Computing
< http://www.mathworks.com/access/helpdesk/help/techdoc/matlab.html > - MATLAB Documentation.
< http://www.mathworks.com/support/ > - The MathWorks Support.
< http://www.mathworks.com/matlabcentral/ > - MATLAB Central.
< http://www.mathworks.com/matlabcentral/fileexchange/ > - MATLAB Central File Exchange.