Difference between revisions of "How to MEX MSlice"
Line 26: | Line 26: | ||
The default compiler under Ubuntu is gfortran, but the default configuration options for Matlab 64-bit make the compiler to generate 4-bit pointers. This lead to normal compilation of the mex files but crash after you try to do anything. To avoid this you have to modify your mexopt.sh file (usually located in your ~/.matlab/R20XXx folder) and force Fortran preprocessor to use 8-bit pointers. For gfortran4.4 it would be adding option -D__x86_64__ to | The default compiler under Ubuntu is gfortran, but the default configuration options for Matlab 64-bit make the compiler to generate 4-bit pointers. This lead to normal compilation of the mex files but crash after you try to do anything. To avoid this you have to modify your mexopt.sh file (usually located in your ~/.matlab/R20XXx folder) and force Fortran preprocessor to use 8-bit pointers. For gfortran4.4 it would be adding option -D__x86_64__ to | ||
$FFLAG='-fexceptions -fbackslash -D__x86_64__' | $FFLAG='-fexceptions -fbackslash -D__x86_64__' | ||
− | line in Fortran configuration. | + | line in Fortran configuration part. |
Revision as of 09:29, 20 September 2011
To create the mex files from the Fortran and C code, you need to MEX the Fortran and C source code files included with the mslice distribution. Each distribution will have the files MEXed in the correct format for that distribution. However, if you're a developer or if you want to use a system not currently supported, you can MEX the files yourself. These Fortran and C files are included with every distribution.
How To MEX
If using an operating system that does not currently have a release of mslice, then you can MEX mslice yourself (if possible). You need to have:
- A Fortran compiler compiler that is compatible with your version of Matlab.
- Matlab 7.1 or above
- The latest stable version of Mslice is available from the repository at (Mslice trunk)
To MEX the files yourself:
- Download any Windows distribution of mslice and unzip to a folder of your choice.
- Follow the setup instructions.
- Open Matlab
- Type >> mslice_mex.
- You will be asked to configure your Fortran or C compiler. You have to select Fortran or C compiler under Windows, which will build Fortran or C part of the Mslice accordingly. You may ignore this if your Fortran and C compilers are already configured under Unix.
- You will then be asked for your C compiler. Choose an appropriate compiler in the same way.
- A success or fail message will be displayed. If fail , you can try to build code with different mslice_mex options, which you can get from mslice_mex description. Or contact Mslice support team who will probably be able to help you.
Note to users of recent 64-bit versions of Matlab under Ubuntu64 (September 2011)
The default compiler under Ubuntu is gfortran, but the default configuration options for Matlab 64-bit make the compiler to generate 4-bit pointers. This lead to normal compilation of the mex files but crash after you try to do anything. To avoid this you have to modify your mexopt.sh file (usually located in your ~/.matlab/R20XXx folder) and force Fortran preprocessor to use 8-bit pointers. For gfortran4.4 it would be adding option -D__x86_64__ to
$FFLAG='-fexceptions -fbackslash -D__x86_64__'
line in Fortran configuration part.