Error installing Dynare on Ubuntu 18.04

I followed the steps for the Ubuntu installation, but I get the following error message:

install: cannot stat ‘/usr/src/matlab/dynare-matlab/mex/matlab/*’: No such file or directory
dpkg: error processing package dynare-matlab (–configure):
installed dynare-matlab package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:

Is there an alternative way of installing Dynare? Would downloading the Windows version and setting path to that folder still work in Ubuntu?

Thank you for your help.

Hi @rmarto,

Most likely, this means that the compilation of the MEX files for MATLAB failed.

Where is MATLAB installed on your harddrive? Once you have determined the MATLAB installation path, you should run dpkg-reconfigure dynare-matlab to give it the right location, and it will try to recompile. By the way, this should also produce a compilation log, that you can post here.

Note that one possible explanation of the problem is that your MATLAB version is too recent for the version of Dynare that is shipped in Ubuntu 18.04 (i.e. Dynare 4.5.4). If this is the case, you should upgrade to Ubuntu 20.04 (actually, you should upgrade anyways).

To answer your other question: it’s not possible to use the Windows version on Ubuntu. The only other installation method is to compile Dynare from source, but it’s more complex.

Hi Sebastian,

Thanks for your reply.
I have Matlab R2018b, which is installed in /home/.matlab/R2018b. When I do dpkg-reconfigure dynare-matlab, it says that dynare-matlab is broken or not fully installed. How should I give it the right location as you mention?

Many thanks.

Sorry, you need to do dpkg-reconfigure matlab-support.

However I doubt that your MATLAB is located under ~/.matlab/R2018b. This place is used by MATLAB to store some data, but it’s not the installation path.

Usually MATLAB is installed under something like /usr/local/MATLAB/R2018b.

Great, the dpkg-reconfigure matlab-support worked and you are correct the path is /usr/local/MATLAB/R2018b. The reconfiguration implied changing some library extensions, which I accepted. I did apt-get install dynare again and I still get some errors with dynare-matlab. What should I do?

Please post more technical details (in particular the log file that’s created in /tmp). I can’t help otherwise.

Thanks, here it is:

`debian-matlab-mexhelper 0.0.18

Copyright (C) 2010-2011 Michael Hanke

Licensed under GNU Public License version 3 or later.
This is free software; see the source for copying conditions. There is NO

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):
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:
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… no
checking for mawk… mawk
checking whether make sets $(MAKE)… yes
checking whether make supports nested variables… yes
checking build system type… x86_64-pc-linux-gnu
checking host system type… x86_64-pc-linux-gnu
checking for MATLAB prefix… /usr/local/MATLAB/R2018b
checking whether to enable MATLAB support… yes
checking for MATLAB version… unknown
checking for MEX-file suffix… mexa64
setting MEX-file suffix to .mexa64
checking for MATLAB machine architecture… glnxa64
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 whether gcc understands -c and -o together… yes
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 ar… ar
checking the archiver (ar) interface… ar
checking if compiler needs -Werror to reject unknown flags… no
checking for the pthreads library -lpthreads… no
checking whether pthreads work without any flags… no
checking whether pthreads work with -Kthread… no
checking whether pthreads work with -kthread… no
checking for the pthreads library -llthread… no
checking whether pthreads work with -pthread… yes
checking for joinable pthread attribute… PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads… no
checking for PTHREAD_PRIO_INHERIT… yes
checking for dlopen in -ldl… yes
checking how to run the C preprocessor… gcc -E
checking for grep that handles long lines and -e… /bin/grep
checking for egrep… /bin/grep -E
checking for ANSI C header files… yes
checking for sys/types.h… yes
checking for sys/stat.h… yes
checking for stdlib.h… yes
checking for string.h… yes
checking for memory.h… yes
checking for strings.h… yes
checking for inttypes.h… yes
checking for stdint.h… yes
checking for unistd.h… yes
checking gsl/gsl_cdf.h usability… no
checking gsl/gsl_cdf.h presence… no
checking for gsl/gsl_cdf.h… no
checking for cos in -lm… yes
checking for cblas_dgemm in -lgslcblas… no
checking for gsl_cdf_ugaussian_P in -lgsl… no
checking for compress in -lz… yes
checking for H5Fcreate in -lhdf5… no
checking matio.h usability… yes
checking matio.h presence… yes
checking for matio.h… yes
checking for Mat_Open in -lmatio… yes
checking how to get verbose linking output from gfortran… -v
checking for Fortran 77 libraries of gfortran… -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/…/…/…/…/lib -L/lib/x86_64-linux-gnu -L/lib/…/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/…/lib -L/usr/lib/gcc/x86_64-linux-gnu/7/…/…/… -lgfortran -lm -lquadmath
checking for dummy main to link with Fortran 77 libraries… none
checking for Fortran 77 name-mangling scheme… lower case, underscore, no extra underscore
checking for sb02od_ in -lslicot_pic… no

Dynare is now configured for building the following components…

Binaries (with “make”):
MEX files for MATLAB (except those listed below): no (missing MATLAB, or unknown version, or unknown architecture)
k-order and dynare_simul MEX files for MATLAB: yes
MS-SBVAR MEX files for MATLAB: no (missing GSL)
Kalman Steady State MEX file for MATLAB: no (missing SLICOT)
M2HTML documentation: no

checking that generated files are newer than configure… done
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: creating kalman_steady_state/Makefile
config.status: creating ms_sbvar/Makefile
config.status: creating block_kalman_filter/Makefile
config.status: creating sobol/Makefile
config.status: creating local_state_space_iterations/Makefile
config.status: executing depfiles commands
make[1]: Entering directory ‘/usr/src/matlab/dynare-matlab/mex/build/matlab’
make[1]: Nothing to be done for ‘all-am’.
make[1]: Leaving directory ‘/usr/src/matlab/dynare-matlab/mex/build/matlab’
mkdir -p /usr/lib/dynare/mex/matlab && install -m644 /usr/src/matlab/dynare-matlab/mex/matlab/* /usr/lib/dynare/mex/matlab`

What happens is that the Debian package for Dynare fails to detect your version of MATLAB. This is due to an incompatibility between your version of MATLAB (R2018b) and the version of the Dynare package (4.5.4-1). The former is too recent for the latter.

You have basically two options:
— either use an older version of MATLAB. I think R2017b will be fine.
— or upgrade to Ubuntu 20.04 (which has a much more recent version of Dynare).

If this is your personal computer, then I would recommend the second option, because you will have to upgrade anyways at some point.