# Problem with mex files

**URL:** <https://forum.dynare.org/t/problem-with-mex-files/1028>\
**Category:** Dynare help (legacy posts)\
**Created:** [17 April 2009 20:16 UTC](https://forum.dynare.org/t/problem-with-mex-files/1028 "2009-04-17T20:16:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![marv](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/8e8cbc/32.png) [@marv](https://forum.dynare.org/u/marv)\
**Post date:** [17 April 2009 20:16 UTC](https://forum.dynare.org/t/problem-with-mex-files/1028/1 "2009-04-17T20:16:41Z")

</div>

Hi,  
I am trying to install Dynare on Linux (Red Hat4, 64-bit, gcc4) for Matlab7.4. According the DynareWiki, after running the function build\_matlab.m (to compile the mex file), Matlab exits if compilation is successful. In case of error, Matlab will stop and display the error message. In my case, Matlab does not exist but I don`t get any error.

However when I try to run an example I get the following error message:

Configuring Dynare …  
[mex] Generalized QZ.  
[mex] Sylvester equation solution.  
[mex] Kronecker products.  
[mex] Sparse kronecker products.

Starting Dynare …  
Starting preprocessing of the model file …  
WARNING: Alt\_Ex1\_kat.mod:9.11-25: Symbol beta declared twice.  
6 equation(s) found  
Processing derivation …  
Processing Order 1… done  
Processing Order 2… done  
Processing outputs …  
Preprocessing completed.  
Starting Matlab computing …

* * *

```
   Segmentation violation detected at Fri Apr 17 16:14:23 2009

```

* * *

Configuration:  
MATLAB Version: 7.4.0.287 (R2007a)  
MATLAB License: 288117  
Operating System: Linux 2.6.9-42.0.8.ELsmp #1 SMP Tue Jan 23 12:49:51 EST 2007 x86\_64  
GNU C Library: 2.3.4 stable  
Window System: Citrix Systems Inc (56668), display scu04545:12.0  
Current Visual: 0x23 (class 4, depth 24)  
Virtual Machine: Java 1.5.0\_04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode  
Default Charset: UTF-8

Register State:  
rax = 0000000000000003 rbx = 0000007f00000001  
rcx = 0000000000000006 rdx = 0000000000000001  
rbp = 0000000000000001 rsi = 0000000000000003  
rdi = 0000000000000002 rsp = 0000007fbffec620  
r8 = 0000007fbfff4850 r9 = 0000002aa09f41d8  
r10 = 0000007fbffe93e0 r11 = 0000007fbfff47fc  
r12 = 0000000000000006 r13 = 0000007fbfff4850  
r14 = 0000007fbfff47fc r15 = 0000000000000003  
rip = 0000002a9cab5351 flg = 0000000000010206

Stack Trace:

This error was detected while a MEX-file was running. If the MEX-file  
is not an official MathWorks function, please examine its source code  
for errors. Please consult the External Interfaces Guide for information  
on debugging MEX-files.

If it is an official MathWorks function, please  
follow these steps to report this problem to The MathWorks so we  
have the best chance of correcting it:

The next time MATLAB is launched under typical usage, a dialog box will  
open to help you send the error log to The MathWorks. Alternatively, you  
can send an e-mail to [segv@mathworks.com](mailto:segv@mathworks.com) with the following file attached:  
/home/asd/marv/matlab\_crash\_dump.13194

If the problem is reproducible, please submit a Service Request via:  
[mathworks.com/support/contac … est\_1.html](http://www.mathworks.com/support/contact_us/ts/help_request_1.html)

A technical support engineer might contact you with further information.

Thank you for your help. Save your workspace and restart MATLAB.

Error in ==\> dr1 at 598  
B1 = B\*A\_times\_B\_kronecker\_C(dr.ghxx,hx,hu1);

Error in ==\> resol at 101  
[dr,info,M\_,options\_,oo\_] = dr1(dr,check\_flag,M\_,options\_,oo\_);

Error in ==\> stoch\_simul at 40  
[oo\_.dr, info] = resol(oo\_.steady\_state,0);

Error in ==\> Alt\_Ex1\_kat at 127  
info = stoch\_simul(var\_list\_);

Error in ==\> dynare at 102  
evalin(‘base’,fname) ;

Any help on that would be appreciate.

When I run the function build\_matlab.m this is the output I get in Matlab:

> > build\_matlab  
> > Compiling mjdgges…  
> > → mexopts.sh sourced from directory (DIR = $MATLAB/bin)  
> > FILE = /apps/matlab74/bin/mexopts.sh

* * *

## → MATLAB = /apps/matlab74 → CC = gcc → CC flags: CFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUG CLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++ arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → CXX = g++ → CXX flags: CXXFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O -DNDEBUG CXXLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → FC = g95 → FC flags: FFLAGS = -fPIC -fno-omit-frame-pointer -fexceptions FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → LD = gcc → Link flags: LDFLAGS = -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexa64 arguments = -lmwlapack → LDCXX = → Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = arguments = -lmwlapack

→ gcc -c -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG mjdgges/mjdgges.c -o ../2007a/mjdgges.o

→ gcc -c -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG /apps/matlab74/extern/src/mexversion.c -o ../2007a/mexversion.o

→ gcc -O -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined -o ../2007a/mjdgges.mexa64 ../2007a/mjdgges.o ../2007a/mexversion.o -lmwlapack -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++

## Compiling sparse\_hessian\_times\_B\_kronecker\_C… → mexopts.sh sourced from directory (DIR = $MATLAB/bin) FILE = /apps/matlab74/bin/mexopts.sh

## → MATLAB = /apps/matlab74 → CC = gcc → CC flags: CFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUG CLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++ arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → CXX = g++ → CXX flags: CXXFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O -DNDEBUG CXXLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → FC = g95 → FC flags: FFLAGS = -fPIC -fno-omit-frame-pointer -fexceptions FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → LD = g++ → Link flags: LDFLAGS = -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexa64 arguments = -lmwlapack → LDCXX = → Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = arguments = -lmwlapack

→ g++ -c -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG kronecker/sparse\_hessian\_times\_B\_kronecker\_C.cc -o ../2007a/sparse\_hessian\_times\_B\_kronecker\_C.o

→ gcc -c -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG /apps/matlab74/extern/src/mexversion.c -o ../2007a/mexversion.o

→ g++ -O -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined -o ../2007a/sparse\_hessian\_times\_B\_kronecker\_C.mexa64 ../2007a/sparse\_hessian\_times\_B\_kronecker\_C.o ../2007a/mexversion.o -lmwlapack -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm

## Compiling A\_times\_B\_kronecker\_C… → mexopts.sh sourced from directory (DIR = $MATLAB/bin) FILE = /apps/matlab74/bin/mexopts.sh

## → MATLAB = /apps/matlab74 → CC = gcc → CC flags: CFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUG CLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++ arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → CXX = g++ → CXX flags: CXXFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O -DNDEBUG CXXLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → FC = g95 → FC flags: FFLAGS = -fPIC -fno-omit-frame-pointer -fexceptions FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → LD = g++ → Link flags: LDFLAGS = -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexa64 arguments = -lmwlapack → LDCXX = → Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = arguments = -lmwlapack

→ g++ -c -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG kronecker/A\_times\_B\_kronecker\_C.cc -o ../2007a/A\_times\_B\_kronecker\_C.o

→ gcc -c -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG /apps/matlab74/extern/src/mexversion.c -o ../2007a/mexversion.o

→ g++ -O -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined -o ../2007a/A\_times\_B\_kronecker\_C.mexa64 ../2007a/A\_times\_B\_kronecker\_C.o ../2007a/mexversion.o -lmwlapack -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm

## Compiling gensylv… → mexopts.sh sourced from directory (DIR = $MATLAB/bin) FILE = /apps/matlab74/bin/mexopts.sh

## → MATLAB = /apps/matlab74 → CC = gcc → CC flags: CFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUG CLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++ arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB → CXX = g++ → CXX flags: CXXFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O -DNDEBUG CXXLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB → FC = g95 → FC flags: FFLAGS = -fPIC -fno-omit-frame-pointer -fexceptions FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB → LD = g++ → Link flags: LDFLAGS = -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexa64 arguments = -lmwlapack -lmwlapack → LDCXX = → Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = arguments = -lmwlapack -lmwlapack

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/matlab/gensylv.cpp -o ../2007a/gensylv.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/BlockDiagonal.cpp -o ../2007a/BlockDiagonal.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/GeneralMatrix.cpp -o ../2007a/GeneralMatrix.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/GeneralSylvester.cpp -o ../2007a/GeneralSylvester.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/IterativeSylvester.cpp -o ../2007a/IterativeSylvester.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/KronUtils.cpp -o ../2007a/KronUtils.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/KronVector.cpp -o ../2007a/KronVector.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/QuasiTriangular.cpp -o ../2007a/QuasiTriangular.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/QuasiTriangularZero.cpp -o ../2007a/QuasiTriangularZero.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/SchurDecomp.cpp -o ../2007a/SchurDecomp.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/SchurDecompEig.cpp -o ../2007a/SchurDecompEig.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/SimilarityDecomp.cpp -o ../2007a/SimilarityDecomp.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/SylvException.cpp -o ../2007a/SylvException.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/SylvMatrix.cpp -o ../2007a/SylvMatrix.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/SylvMemory.cpp -o ../2007a/SylvMemory.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/SylvParams.cpp -o ../2007a/SylvParams.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/TriangularSylvester.cpp -o ../2007a/TriangularSylvester.o

→ g++ -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG gensylv/cc/Vector.cpp -o ../2007a/Vector.o

→ gcc -c -Igensylv/cc -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions -DNO\_BLAS\_H -DNO\_LAPACK\_H -DMATLAB -O -DNDEBUG /apps/matlab74/extern/src/mexversion.c -o ../2007a/mexversion.o

→ g++ -O -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined -o ../2007a/gensylv.mexa64 ../2007a/gensylv.o ../2007a/BlockDiagonal.o ../2007a/GeneralMatrix.o ../2007a/GeneralSylvester.o ../2007a/IterativeSylvester.o ../2007a/KronUtils.o ../2007a/KronVector.o ../2007a/QuasiTriangular.o ../2007a/QuasiTriangularZero.o ../2007a/SchurDecomp.o ../2007a/SchurDecompEig.o ../2007a/SimilarityDecomp.o ../2007a/SylvException.o ../2007a/SylvMatrix.o ../2007a/SylvMemory.o ../2007a/SylvParams.o ../2007a/TriangularSylvester.o ../2007a/Vector.o ../2007a/mexversion.o -lmwlapack -lmwlapack -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm

## Compiling simulate… → mexopts.sh sourced from directory (DIR = $MATLAB/bin) FILE = /apps/matlab74/bin/mexopts.sh

## → MATLAB = /apps/matlab74 → CC = gcc → CC flags: CFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUG CLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++ arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → CXX = g++ → CXX flags: CXXFLAGS = -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O -DNDEBUG CXXLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → FC = g95 → FC flags: FFLAGS = -fPIC -fno-omit-frame-pointer -fexceptions FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DNO\_BLAS\_H -DNO\_LAPACK\_H → LD = g++ → Link flags: LDFLAGS = -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexa64 arguments = → LDCXX = → Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = arguments =

→ g++ -c -Isimulate -I../../preprocessor/include -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG simulate/simulate.cc -o ../2007a/simulate.o

→ g++ -c -Isimulate -I../../preprocessor/include -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG simulate/Interpreter.cc -o ../2007a/Interpreter.o

→ g++ -c -Isimulate -I../../preprocessor/include -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG simulate/Mem\_Mngr.cc -o ../2007a/Mem\_Mngr.o

→ g++ -c -Isimulate -I../../preprocessor/include -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG simulate/SparseMatrix.cc -o ../2007a/SparseMatrix.o

→ gcc -c -Isimulate -I../../preprocessor/include -I/apps/matlab74/extern/include -DMATLAB\_MEX\_FILE -fPIC -fno-omit-frame-pointer -ansi -D\_GNU\_SOURCE -pthread -fexceptions -DNO\_BLAS\_H -DNO\_LAPACK\_H -O -DNDEBUG /apps/matlab74/extern/src/mexversion.c -o ../2007a/mexversion.o

→ g++ -O -pthread -shared -Wl,–version-script,/apps/matlab74/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined -o ../2007a/simulate.mexa64 ../2007a/simulate.o ../2007a/Interpreter.o ../2007a/Mem\_Mngr.o ../2007a/SparseMatrix.o ../2007a/mexversion.o -Wl,-rpath-link,/apps/matlab74/bin/glnxa64 -L/apps/matlab74/bin/glnxa64 -lmx -lmex -lmat -lm

> >

---

<div class="post-metadata">

**Author:** ![MichelJuillard](https://forum.dynare.org/user_avatar/forum.dynare.org/micheljuillard/32/5318_2.png) [@MichelJuillard](https://forum.dynare.org/u/MichelJuillard)\
**Post date:** [18 April 2009 09:22 UTC](https://forum.dynare.org/t/problem-with-mex-files/1028/2 "2009-04-18T09:22:26Z")

</div>

We had problems trying to fix the code for the DLL to be compatible with Matlab 7.8 (2009).  
I made some correction in the snapshot, could you try to see if it fixes your problem?

Matlab doesn’t exit after build\_matlab anymore. I will correct the wiki.

Thanks for reporting the problem

Michel

---

<div class="post-metadata">

**Author:** ![marv](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/8e8cbc/32.png) [@marv](https://forum.dynare.org/u/marv)\
**Post date:** [20 April 2009 19:12 UTC](https://forum.dynare.org/t/problem-with-mex-files/1028/3 "2009-04-20T19:12:19Z")

</div>

Hi,  
I am using Matlab 7.4 not 7.8, on a 64 bit machine (linux red hat 4 with gcc4). I will try with the snaphsot.

Thanks!  
Katerine

---

<div class="post-metadata">

**Author:** ![marv](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/8e8cbc/32.png) [@marv](https://forum.dynare.org/u/marv)\
**Post date:** [21 April 2009 16:10 UTC](https://forum.dynare.org/t/problem-with-mex-files/1028/4 "2009-04-21T16:10:02Z")

</div>

Hi,

I tried with the snapshot and it still does not work. If I compile the dll with Matlab 7.1 instead of 7.4(64 bit linux machine) using the command build\_matlab it seems to work. I would like to use Matlab 7.4.

---

<div class="post-metadata">

**Author:** ![MichelJuillard](https://forum.dynare.org/user_avatar/forum.dynare.org/micheljuillard/32/5318_2.png) [@MichelJuillard](https://forum.dynare.org/u/MichelJuillard)\
**Post date:** [21 April 2009 20:47 UTC](https://forum.dynare.org/t/problem-with-mex-files/1028/5 "2009-04-21T20:47:30Z")

</div>

Hi,

can you post the log of build\_matlab with Matlab 7.4? Note that you need to redo build\_matlab if you change between Matlab 7.1 and Matlab 7.4

Best

Michel

---

<div class="post-metadata">

**Author:** ![marv](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/8e8cbc/32.png) [@marv](https://forum.dynare.org/u/marv)\
**Post date:** [24 April 2009 13:49 UTC](https://forum.dynare.org/t/problem-with-mex-files/1028/6 "2009-04-24T13:49:43Z")

</div>

Hi,

I downloaded the snapshot again and everything seems to work fine! I did not run the function build\_matlab.m. Do we have to run this function? Not sure if I understand the role of this function.

Also when I compile the preprocessor I get the following warning:

make: warning: Clock skew detected. Your build may be incomplete.

---

<div class="post-metadata">

**Author:** ![MichelJuillard](https://forum.dynare.org/user_avatar/forum.dynare.org/micheljuillard/32/5318_2.png) [@MichelJuillard](https://forum.dynare.org/u/MichelJuillard)\
**Post date:** [25 April 2009 08:57 UTC](https://forum.dynare.org/t/problem-with-mex-files/1028/7 "2009-04-25T08:57:05Z")

</div>

When you compile Dynare, you need to do two different things

1. compile the preprocessor with _make_
2. compile the DLL that Dynare uses to accelerate Matlab with _build\_matlab_

If you don’t do 2), Dynare will work, but will be slower

The clock skew warning means that some of the files that you create during compilation have date/time older than the source they were compiled from. This can come from a difference in the clock between your computer and our web server. I don’t think that it can have adverse consequences for compiling Dynare.

Best

Michel

---

<div class="post-metadata">

**Author:** ![marv](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/8e8cbc/32.png) [@marv](https://forum.dynare.org/u/marv)\
**Post date:** [29 April 2009 20:17 UTC](https://forum.dynare.org/t/problem-with-mex-files/1028/8 "2009-04-29T20:17:58Z")

</div>

Hi,

Everything works fine if I don’t run the command build\_matlab. If I run this command I can’t run any examples. I am using the snapshot with Matlab 7.4 on Linux 64 bit. The error I get is

dynare Alt\_Ex1

Configuring Dynare …  
[mex] Generalized QZ.  
[mex] Sylvester equation solution.  
[mex] Kronecker products.  
[mex] Sparse kronecker products.  
[mex] Fast model evaluation.

Starting Dynare …  
Starting preprocessing of the model file …  
WARNING: Alt\_Ex1.mod:6.11-25: Symbol beta declared twice.  
Found 6 equation(s).  
Evaluating expressions…done  
Computing static model derivatives:

- order 1  
Computing dynamic model derivatives:
- order 1
- order 2  
Processing outputs …done  
Preprocessing completed.  
Starting Matlab computing …

* * *

```
   Segmentation violation detected at Wed Apr 29 16:15:02 2009

```

* * *

Configuration:  
MATLAB Version: 7.4.0.287 (R2007a)  
MATLAB License: 288117  
Operating System: Linux 2.6.9-42.0.8.ELsmp #1 SMP Tue Jan 23 12:49:51 EST 2007 x86\_64  
GNU C Library: 2.3.4 stable  
Window System: Citrix Systems Inc (56668), display scu04545:12.0  
Current Visual: 0x23 (class 4, depth 24)  
Virtual Machine: Java 1.5.0\_04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode  
Default Charset: UTF-8

Register State:  
rax = 0000000000000003 rbx = 0000007f00000001  
rcx = 0000000000000006 rdx = 0000000000000001  
rbp = 0000000000000001 rsi = 0000000000000003  
rdi = 0000000000000002 rsp = 0000007fbffec630  
r8 = 0000007fbfff4860 r9 = 0000002aa0a0d3c8  
r10 = 00000000015d6ff0 r11 = 0000007fbfff4814  
r12 = 0000000000000006 r13 = 0000007fbfff4860  
r14 = 0000007fbfff4814 r15 = 0000000000000003  
rip = 0000002a9cab5351 flg = 0000000000010206

Stack Trace:

This error was detected while a MEX-file was running. If the MEX-file  
is not an official MathWorks function, please examine its source code  
for errors. Please consult the External Interfaces Guide for information  
on debugging MEX-files.

If it is an official MathWorks function, please  
follow these steps to report this problem to The MathWorks so we  
have the best chance of correcting it:

The next time MATLAB is launched under typical usage, a dialog box will  
open to help you send the error log to The MathWorks. Alternatively, you  
can send an e-mail to [segv@mathworks.com](mailto:segv@mathworks.com) with the following file attached:  
/home/asd/marv/matlab\_crash\_dump.418

If the problem is reproducible, please submit a Service Request via:  
[mathworks.com/support/contac … est\_1.html](http://www.mathworks.com/support/contact_us/ts/help_request_1.html)

A technical support engineer might contact you with further information.

Thank you for your help. Save your workspace and restart MATLAB.

Error in ==\> dr1 at 615  
B1 = B\*A\_times\_B\_kronecker\_C(dr.ghxx,hx,hu1);

Error in ==\> resol at 118  
[dr,info,M\_,options\_,oo\_] = dr1(dr,check\_flag,M\_,options\_,oo\_);

Error in ==\> stoch\_simul at 40  
[oo\_.dr, info] = resol(oo\_.steady\_state,0);

Error in ==\> Alt\_Ex1 at 124  
info = stoch\_simul(var\_list\_);

Error in ==\> dynare at 125  
evalin(‘base’,fname) ;
