MSVC issue

I use MATLAB R2012a, Visual Studio Professional 2010, and the Dynare 4.3.2 on a Windows machine.

Here is the error I encountered when executing Dynare. (Note: I have no problem running this on a Mac nor in Ubuntu.)

[code]LINK : error LNK2001: unresolved external symbol Dynamic
C:\Users[username_removed]\AppData\Local\Temp\mex_3EYSFq\templib.x : fatal error LNK1120: 1 unresolved externals

C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Link of ‘[dynare_mod_file_removed]_static.mexw64’ failed. [/code]

Any ideas what is causing this?

Thanks!

Hi, which Windows are you using? And what exactly did you do to get this error message? Lastly, could you please post the things Dynare says after startup, like:

[quote]Configuring Dynare …
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.[/quote]

jpfeifer: I just ran Dynare without use_dll and it ran as expected.

In case there is a bug with use_dll, here is the information you asked for.

I use Windows 7 64-bit.

The command I issue Matlab is dynare [mod file name] msvc

Here is what Dynare says after start up:

[code]Configuring Dynare …
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.3.2).
Starting preprocessing of the model file …
Found 23 equation(s).
Evaluating expressions…done
Computing static model derivatives:

  • order 1
    Computing dynamic model derivatives:
  • order 1
  • order 2
  • order 3
    Processing outputs …done
    Preprocessing completed.
    Starting MATLAB/Octave computing.

LINK : error LNK2001: unresolved external symbol Dynamic
C:\Users[username]\AppData\Local\Temp\mex_PKpfKq\templib.x : fatal error LNK1120: 1 unresolved externals

C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Link of ‘[mod name]_static.mexw64’ failed. [/code]

Thanks!

I can replicate the issue on my machine. We will look into it and keep you posted.

This is a bug in Dynare, that will be fixed in the next release.

In the meantime, you can download a new preprocessor binary there: dynare.org/sebastien/4.3.2+msvc/dynare_m.exe

Replace your existing binary by that new one, and compilation with MSVC should now work.

Thanks for reporting this,

Hello to everyone!

I also have a similar error while trying to run a mod file with dynare 4.4.3, using Matlab R2012a (32 bit) and Windows 7 Ultimate.

I have downloaded Microsoft Visual C++ Professional SP1 as compiler for mex files (in order to be able to use the command use_dll), but when I write in Matlab the command >> mex –setup I obtain the following error:

C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: ‘–setup’ not found.

Error using mex (line 206)
Unable to complete successfully.

Can you please indicate me in what subfolder of Matlab should I extract the new installation for Microsoft Visual C++ Professional SP1? As I have tried to use the unzip command: >> unzip(C:\Users\oana\Downloads\vcredist_x86(1),matlabroot) and the following error occurs: unzip(C:\Users\oana\Downloads\vcredist_x86(1),matlabroot)
|
Error: Unexpected MATLAB operator.

Most probably due to the inappropriate installation of compiler, when running the mod file using the command: dynare file_name msvc, the following error occurs:

unrecognized option -export:Dynamic

C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Link of ‘mze_dynamic.mexw32’ failed.

Error using mex (line 206)
Unable to complete successfully.
Error in mze (line 748)
eval(‘mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" mze_dynamic.c mze_dynamic_mex.c’)
Error in dynare (line 180)
evalin(‘base’,fname) ;

Many thanks in advance for your support!

This is strange, because the

is a Matlab command that is not related to Dynare. What does Matlab return when you type

Also, you need to check which compiler is supported by your Matlab version: it.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/SystemRequirements-Release2012a_SupportedCompilers.pdf
These compilers must be installed properly, not just unzipped. And they do not belong into the Matlab directory.

Hi and many thanks for your answer.

The answer is that when I write the code:>>which mex
the output is:
C:\Program Files\MATLAB\R2012a\toolbox\matlab\general\mex.m

Instead, when I write the code:>> mex -setup
the output is:

Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
mathworks.com/support/compil … win32.html

Please choose your compiler for building MEX-files:

Would you like mex to locate installed compilers [y]/n? y

Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2012a\sys\lcc

[0] None

Compiler: 1

Please verify your choices:

Compiler: Lcc-win32 C 2.4.1
Location: C:\PROGRA~1\MATLAB\R2012a\sys\lcc

Are these correct [y]/n? y

Trying to update options file: C:\Users\oana\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2012a\bin\win32\mexopts\lccopts.bat

Done . . .


Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
mathworks.com/help/techdoc/m … nue-1.html
Building with the -largeArrayDims option enables the new API.


Thanks in advance for your support!

That all looks good. You have selected a compiler. What happens now when you try to run the mod-file?

Hi again,

When running the mod file, the error message is described below.
Many thanks for your help.

dynare mze

Configuring Dynare …
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.4.3).
Starting preprocessing of the model file …
Substitution of endo lags >= 2: added 4 auxiliary variables and equations.
Found 96 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/Octave computing.

Error using mze (line 748)
When using the USE_DLL option, you must give either ‘cygwin’ or ‘msvc’ option to the ‘dynare’ command
Error in dynare (line 180)
evalin(‘base’,fname) ;

You need to call it with

Hi,
I have also tried this to add “msvc” at the end of dynare function, but the error is similar, as described below.
Excuse me for my perseverance, but I really don’t know how to solve this.

Many thanks,

dynare mze msvc

Configuring Dynare …
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.4.3).
Starting preprocessing of the model file …
Substitution of endo lags >= 2: added 4 auxiliary variables and equations.
Found 96 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/Octave computing.

unrecognized option -export:Dynamic

C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Link of ‘mze_dynamic.mexw32’ failed.

Error using mex (line 206)
Unable to complete successfully.
Error in mze (line 748)
eval(‘mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" mze_dynamic.c mze_dynamic_mex.c’)
Error in dynare (line 180)
evalin(‘base’,fname) ;

This seems to be an incompatibility between the Matlab version, the compiler and the Dynare version. Have you tried passing

instead of msvc?