| 1 |
@c Copyright (c) 2015-2026, The matio contributors |
| 2 |
@c Copyright (c) 2012-2014, Christopher C. Hulbert |
| 3 |
@c All rights reserved. |
| 4 |
@c |
| 5 |
@c Redistribution and use in source and binary forms, with or without |
| 6 |
@c modification, are permitted provided that the following conditions are met: |
| 7 |
@c |
| 8 |
@c 1. Redistributions of source code must retain the above copyright notice, this |
| 9 |
@c list of conditions and the following disclaimer. |
| 10 |
@c |
| 11 |
@c 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 |
@c this list of conditions and the following disclaimer in the documentation |
| 13 |
@c and/or other materials provided with the distribution. |
| 14 |
@c |
| 15 |
@c THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 |
@c AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 |
@c IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 18 |
@c DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 19 |
@c FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 20 |
@c DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 21 |
@c SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 22 |
@c CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 23 |
@c OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 |
@c OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 |
|
| 26 |
@chapter Building matio |
| 27 |
@section Quick Build Guide |
| 28 |
The primary method for building the software is using @code{configure} followed |
| 29 |
by @code{make}. After building, the testsuite can be executed to test the |
| 30 |
software using @code{make check} (See @ref{Testsuite}. The software can be |
| 31 |
installed using 'make install'. For example, |
| 32 |
|
| 33 |
@verbatim |
| 34 |
$ tar zxf matio-X.Y.Z.tar.gz |
| 35 |
$ cd matio-X.Y.Z |
| 36 |
$ ./configure |
| 37 |
$ make |
| 38 |
$ make check |
| 39 |
$ make install |
| 40 |
@end verbatim |
| 41 |
|
| 42 |
@section Configure Options |
| 43 |
@table @code |
| 44 |
@item --enable-mat73=[yes|no] |
| 45 |
This flag enables/disables the support for version 7.3 MAT files. The option |
| 46 |
only makes sense if built with HDF5 as support for version 7.3 files will be |
| 47 |
disabled if HDF5 is not available. |
| 48 |
@item --enable-extended-sparse=yes |
| 49 |
Enable extended sparse matrix data types not supported in MATLAB. MATLAB only |
| 50 |
supports double-precision sparse data. With this flag, matio will read sparse |
| 51 |
data with other types (i.e. single-precision and integer types). |
| 52 |
@item --with-matlab=DIR |
| 53 |
This option specifies the directory (DIR) with the @code{matlab} program. With |
| 54 |
this option, the testsuite will check that the MAT files written by matio can be |
| 55 |
read into MATLAB (see Section @ref{Testsuite} for more information about the |
| 56 |
testsuite). |
| 57 |
@item --with-zlib=DIR |
| 58 |
This option specifies the prefix where zlib is installed. |
| 59 |
@item --with-hdf5=DIR |
| 60 |
This option specifies the prefix where the HDF5 software is installed. |
| 61 |
@item --with-default-file-ver=[4|5|7.3] |
| 62 |
This option sets the default MAT file version that will be used when writing. |
| 63 |
The default file version is used by the Mat_Create macro and the |
| 64 |
Mat_CreateVer function when MAT_FT_DEFAULT is used for the version argument. |
| 65 |
@item --with-libdir-suffix=suffix |
| 66 |
This option specifies a suffix to apply to library directories when installing |
| 67 |
and looking for dependent libraries (i.e. HDF5 and zlib). For example, some |
| 68 |
multi-arch Linux distributions install 64-bit libraries into lib64 and 32-bit |
| 69 |
libraries into lib. |
| 70 |
@end table |
| 71 |
|
| 72 |
@section CMake build system |
| 73 |
The CMake build system is supported as an alternative build system, |
| 74 |
which usually consists of three steps for configuration, build and |
| 75 |
installation, for example, |
| 76 |
|
| 77 |
@verbatim |
| 78 |
$ tar zxf matio-X.Y.Z.tar.gz |
| 79 |
$ cd matio-X.Y.Z |
| 80 |
$ cmake . |
| 81 |
$ cmake --build . |
| 82 |
$ cmake --install . |
| 83 |
@end verbatim |
| 84 |
|
| 85 |
The following matio specific options for building with CMake are |
| 86 |
available. |
| 87 |
@table @code |
| 88 |
@item MATIO_USE_CONAN:BOOL=OFF |
| 89 |
This option enables the Conan package manager to resolve the library |
| 90 |
dependencies. |
| 91 |
@item MATIO_DEFAULT_FILE_VERSION:STRING=5 |
| 92 |
This option sets the default MAT file version (4,5,7.3) that |
| 93 |
will be used when writing. |
| 94 |
@item MATIO_EXTENDED_SPARSE:BOOL=ON |
| 95 |
This option enables extended sparse matrix data types not |
| 96 |
supported in MATLAB. |
| 97 |
@item MATIO_MAT73:BOOL=ON |
| 98 |
This flag enables the support for version 7.3 MAT files. |
| 99 |
@item MATIO_PIC:BOOL=ON |
| 100 |
This option enables position-independent code (PIC), |
| 101 |
i.e., compilation with the @code{-fPIC} flag. It is ignored for |
| 102 |
Visual Studio builds. |
| 103 |
@item MATIO_SHARED:BOOL=ON |
| 104 |
This option builds the matio library as shared object |
| 105 |
(i.e., a dynamic link library on Windows). |
| 106 |
@item MATIO_WITH_HDF5:BOOL=ON |
| 107 |
This option enables CMake to check for availability of the |
| 108 |
HDF5 library (see section 2.1.2 for information about HDF5). |
| 109 |
@item MATIO_WITH_ZLIB:BOOL=ON |
| 110 |
This option enables CMake to check for availability of the |
| 111 |
zlib library (see section 2.1.1 for information about zlib). |
| 112 |
@end table |
| 113 |
|
| 114 |
To help CMake find the HDF5 libraries, set environment variable |
| 115 |
HDF5_DIR to the @emph{cmake/hdf5} directory (containing |
| 116 |
@emph{hdf5-config.cmake}) inside the HDF5 build or installation directory, or |
| 117 |
call cmake with |
| 118 |
@code{-DHDF5_DIR="dir/to/hdf5/cmake/hdf5}. Alternatively call CMake with |
| 119 |
@code{-DCMAKE_PREFIX_PATH="dir/to/hdf5/cmake"}. See the HDF5 instructions |
| 120 |
for more information. Using @emph{hdf5-config.cmake} is recommended over |
| 121 |
using CMake's built-in @emph{FindHDF5}, especially for static builds. |
| 122 |
CMake 3.10 or later is recommended. |
| 123 |
|
| 124 |
@section Visual Studio |
| 125 |
A visual studio solution is provided as visual_studio/matio.sln. The solution is |
| 126 |
set up to build a DLL of the matio library (@emph{libmatio.dll}) and |
| 127 |
@emph{matdump} tool in release mode and assumes HDF5 is available in the |
| 128 |
directory specified by the HDF5_DIR environment variable. The build was tested |
| 129 |
with the HDF5 visual studio pre-built Windows binaries including zlib. |
| 130 |
|
| 131 |
@node Testsuite |
| 132 |
@section Testsuite |
| 133 |
A testsuite is available when building with the GNU autotools. To run the |
| 134 |
testsuite, First configure and build matio. After building run @code{make check} |
| 135 |
to run the testsuite. If matio was built without zlib, the compressed variable |
| 136 |
tests will be skipped. If built without HDF5, the tests for version 7.3 MAT |
| 137 |
files will be skipped. If the path to the MATLAB application was not specified |
| 138 |
(@code{--with-matlab}), the write tests will fail if matio cannot read the file |
| 139 |
and skip if matio can read the file. The write tests will pass if MATLAB is |
| 140 |
available and can also read the file. |
| 141 |
|
| 142 |
To report matio testsuite failures, compress the testsuite.log file in the test |
| 143 |
sub-directory of the build directory. Upload the compressed log file along with |
| 144 |
a bug report (see Section 1.4 for information on reporting bugs). |