Problems installing dynare-matlab on Debian MATLAB R2012a

Hi,

I am experiencing some package compiling errors on my Debian system with dynare-matlab. The system has recently been upgraded MATLAB R2012a. Dynare-matlab was working okay before. This is a 64-bit system running gcc-multilib.

The log file “/tmp/dynare-matlab-mexbuild-1338842708.lkvguW4” is attached.

Setting up dynare-matlab (4.2.5-2) ...
Building Matlab extensions (logfile at /tmp/dynare-matlab-mexbuild-1338842708.lkvguW4)
In file included from ../../../sources/mjdgges/mjdgges.c:23:0:
../../../sources/dynmex.h:30:33: error: invalid suffix "x" on integer constant
../../../sources/dynmex.h:31:13: error: conflicting types for ‘mwIndex’
In file included from /usr/local/MATLAB/extern/include/matrix.h:295:0,
                 from /usr/local/MATLAB/extern/include/mex.h:58,
                 from ../../../sources/dynmex.h:27,
                 from ../../../sources/mjdgges/mjdgges.c:23:
/usr/local/MATLAB/extern/include/tmwtypes.h:797:19: note: previous declaration of ‘mwIndex’ was here
In file included from ../../../sources/mjdgges/mjdgges.c:23:0:
../../../sources/dynmex.h:32:13: error: conflicting types for ‘mwSize’
In file included from /usr/local/MATLAB/extern/include/matrix.h:295:0,
                 from /usr/local/MATLAB/extern/include/mex.h:58,
                 from ../../../sources/dynmex.h:27,
                 from ../../../sources/mjdgges/mjdgges.c:23:
/usr/local/MATLAB/extern/include/tmwtypes.h:796:19: note: previous declaration of ‘mwSize’ was here
In file included from ../../../sources/mjdgges/mjdgges.c:24:0:
../../../sources/dynlapack.h:33:33: error: invalid suffix "x" on integer constant
../../../sources/mjdgges/mjdgges.c: In function ‘mjdgges’:
../../../sources/mjdgges/mjdgges.c:37:35: warning: variable ‘one’ set but not used -Wunused-but-set-variable]
make[1]: *** [mjdgges.o] Error 1
make: *** [all-recursive] Error 1
dpkg: error processing dynare-matlab (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 dynare-matlab
E: Sub-process /usr/bin/dpkg returned an error code (1)

Cannot attach the file into my original post…

The log file “/tmp/dynare-matlab-mexbuild-1338842708.lkvguW4” is pasted here. Sorry for the long post.

root@microcosmos:/tmp# cat dynare-matlab-mexbuild-1338842708.lkvguW4 
debian-matlab-mexhelper 0.0.18

Copyright (C) 2010-2011 Michael Hanke <michael.hanke@gmail.com>

Licensed under GNU Public License version 3 or later.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Written by Michael Hanke.

Attempt to build Matlab extensions

Package name:        dynare-matlab
Source directory:    /usr/src/matlab/dynare-matlab
MEX dir:             /usr/lib/matlab/site/dynare-matlab
M dir:               /usr/share/matlab/site/m/dynare-matlab
Build user (if any): GoJian
Build command:       cd mex/build/matlab && ./configure --with-matlab=$(dirname $(dirname $(readlink -f `which matlab`))) MATLAB_VERSION=$(echo version | matlab -nodesktop -nodisplay -nosplash 2>/dev/null | grep -A2 "ans ="|tail -1| cut -d "." -f 1,2) && make
Install command:     mkdir -p /usr/lib/dynare/mex/matlab && install -m644 /usr/src/matlab/dynare-matlab/mex/matlab/* /usr/lib/dynare/mex/matlab
Clean command:       cd mex/build/matlab && make distclean && rmdir /usr/src/matlab/dynare-matlab/mex/matlab

Attempt to build Matlab extensions:
sudo -H -u GoJian sh -c "cd mex/build/matlab && ./configure --with-matlab=$(dirname $(dirname $(readlink -f `which matlab`))) MATLAB_VERSION=$(echo version | matlab -nodesktop -nodisplay -nosplash 2>/dev/null | grep -A2 "ans ="|tail -1| cut -d "." -f 1,2) && make"
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for MATLAB prefix... /usr/local/MATLAB
checking whether to enable MATLAB support... yes
checking for MATLAB version... >>
checking for MEX-file suffix... mexa64
setting MEX-file suffix to .mexa64
checking for MATLAB machine architecture... glnxa64
checking for a sed that does not truncate output... /bin/sed
checking for options to compile MEX for MATLAB... ok
checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for gfortran... gfortran
checking whether the Fortran 77 compiler works... yes
checking for Fortran 77 compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether gfortran accepts -g... yes
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for ranlib... ranlib
checking whether ln -s works... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for boostlib >= 1.36... yes
checking for dlopen in -ldl... yes
configure:

Dynare is now configured for building the following components...

Binaries (with "make"):
 MEX files for MATLAB:     yes
 M2HTML documentation:     no


configure: creating ./config.status
config.status: creating Makefile
config.status: creating mjdgges/Makefile
config.status: creating kronecker/Makefile
config.status: creating bytecode/Makefile
config.status: creating libdynare++/Makefile
config.status: creating gensylv/Makefile
config.status: creating k_order_perturbation/Makefile
config.status: creating dynare_simul_/Makefile
config.status: executing depfiles commands
Making all in mjdgges
make[1]: Entering directory `/usr/src/matlab/dynare-matlab/mex/build/matlab/mjdgges'
gcc -DPACKAGE_NAME=\"dynare\" -DPACKAGE_TARNAME=\"dynare\" -DPACKAGE_VERSION=\"4.2.5\" -DPACKAGE_STRING=\"dynare\ 4.2.5\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"dynare\" -DVERSION=\"4.2.5\" -DHAVE_MATLAB=1 -DHAVE_PTHREAD=1 -DHAVE_BOOST=/\*\*/ -D_GNU_SOURCE -DNDEBUG -DMATLAB_VERSION=0x -DMATLAB_MEX_FILE -I.   -I/usr/local/MATLAB/extern/include -I../../../sources  -ansi -fexceptions -fPIC -pthread -g -O2 -fno-omit-frame-pointer -Wall -Wno-parentheses -MT mjdgges.o -MD -MP -MF .deps/mjdgges.Tpo -c -o mjdgges.o `test -f '../../../sources/mjdgges/mjdgges.c' || echo './'`../../../sources/mjdgges/mjdgges.c
make[1]: Leaving directory `/usr/src/matlab/dynare-matlab/mex/build/matlab/mjdgges'

The crash occurs because your MATLAB version is not correctly detected.

The quickfix is the following: install MATLAB under /usr/local/MATLAB/R2012a. The path is used to detect the version (I know it’s ugly, but this is because MATLAB does not provide an easier way)

Best,