"Failed to compile the model (does not exist)"

Use this forum to post Vensim related questions.
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

"Failed to compile the model (does not exist)"

Post by RWTH_FCN »

Hello everyone,

I am trying to get an 8 year old model running on a new computer and with a more recent VenSim Version.

When I open my model and try to simulate it, I get the error "Failed to compile the model (does not exist)". I tried to fix that error by adjusting the paths in the mdl.bat (in VenSim/comp) but that did not help.
Can anyone point me in a direction what the reason for that error could be? I didnt find any more infos or other ppl with the same error so far except one where they recommended to adjust the mdl.bat (http://www.ventanasystems.co.uk/forum/v ... php?t=2904).

I am using VENSIM DSS 6.4E and Visual Studio 2013 on a Windows 7 (64bit) computer.

I am thankful for any help.

Cheers
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

I've attached a document that should get you to the point where you can compile models.
To compile models.pdf
(48.49 KiB) Downloaded 330 times
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

Thank you for your quick answer. I followed all steps but I still get the same error. Do you have any other ideas?

Best regards
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

Can you edit your MDL.bat file and paste the contents here so we can see? Don't try to upload the file, the browser will prevent you from doing so.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

Yes, sure. Here you go:

@ECHO OFF
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
if exist mdl.obj del mdl.obj
if exist %3.dll del %3.dll
if .%2 == . goto noinclude
CL /O2 /c /I "%2" /DWIN32 mdl.c
goto aftercomp
:noinclude
CL /O2 /c /DWIN32 mdl.c
:aftercomp
if errorlevel 1 goto :error1
if not exist mdl.obj goto :error2
LINK /DLL /OUT:%3.dll /def:%1sim.def mdl.obj
if errorlevel 1 goto :error3
if not exist %3.dll goto :error3
REM clean up .lib and .exp files - they are not neaded
del %3.lib
del %3.exp
goto :exit
:error1
echo There were errors while compiling - check the paths in mdl.bat in vensim\comp
goto exit2
:error2
echo Unable to compile. You probably need to set paths in mdl.bat in vensim\comp
goto exit2
:error3
echo Errors while linking %3.dll - make sure compiled simulations were properly installed
goto :exit2
:exit2
pause
goto :exit3
:exit
echo ----------
echo Compilation of %3 seems to have been successful.
echo Close this window and continue.
:exit3

_______________________

I did not apply the following steps (18,19,20) of your Instructions since my error doesnt include the LIBC.LIB

18. Occasionally there will be an error compiling. An error mentioning LIBC.LIB will appear. To fix this, edit
the MDL.BAT file again.
19. Locate the line
LINK /DLL /OUT:%3.dll /def:%1sim.def mdl.obj
20. Edit this so that it looks like the following
LINK /DLL /nodefaultlib libc.lib /OUT:%3.dll /def:%1sim.def mdl.obj
21. Try running the model again.
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: "Failed to compile the model (does not exist)"

Post by tomfid »

Does the

Code: Select all

call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
succeed?

The first thing I do is comment out the ECHO OFF statement, so that I can see what errors are generated.
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

Also make the last line of MDL.BAT "pause".

This way the command box will not exit and you can see any errors.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

Thank you for your help. I adjusted the code according to your answers. If I try to run the MDL.BAT now, I get the following error (in the cmd console):

"C:\Program Files (x86)\Vensim\COMP>call "C:\Program Files (x86)\Microsoft Visual
Studio 12.0\VC\bin\vcvars32.bat"

C:\Program Files (x86)\Vensim\COMP>if exist mdl.obj del mdl.obj

C:\Program Files (x86)\Vensim\COMP>if exist .dll del .dll

C:\Program Files (x86)\Vensim\COMP>if . == . goto noinclude

C:\Program Files (x86)\Vensim\COMP>CL /O2 /c /DWIN32 mdl.c
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

mdl.c
c1 : fatal error C1083: Cannot open source file: 'mdl.c': No such file or direct
ory

C:\Program Files (x86)\Vensim\COMP>if errorlevel 1 goto :error1

C:\Program Files (x86)\Vensim\COMP>echo There were errors while compiling - chec
k the paths in mdl.bat in vensim\comp
There were errors while compiling - check the paths in mdl.bat in vensim\comp

C:\Program Files (x86)\Vensim\COMP>goto exit2

C:\Program Files (x86)\Vensim\COMP>pause
Drücken Sie eine beliebige Taste . . ."

I guess this means mdl.c does not exist. But shouldnt mdl.c be created by vensim itself? I tried the steps elaborated in the documentation (https://www.vensim.com/documentation/in ... ?25975.htm). As expected Step 2 fails. I understand that I am supposed to open the SIM.MAK file in Visual Studio, right? Doing so gives me a "Project upgrade failed" error and it doenst open. I can open the SIM.MAK in editor, but how am I supposed to do step 4 now (build the SIM.DLL file)?

Thank you in advance.
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

ok, I think I understand what is happening now.

Vensim calls mdl.bat, it looks like you are running it yourself in a command prompt. Is this correct?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

Yes exactly. I applied your suggested changes (comment out "ECHO OFF" and add a "pause" at the end) to the MDL.BAT. If I then try running the model in VenSim I get the same old error. So i thought I run MDL.BAT in a command prompt, so I can see what errors are occuring whithin that file. Please advise me what my mistake is, and what I could do differently.

Thank you!
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

In Vensim, have you set up the path to the comp folder?

Tools->Options->Startup, click the browse button next to "Compiled simulation path".
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

Yes the path to the comp folder is set in Vensim.
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

And if you have set this up correctly, Vensim should call the MDL.BAT file and pause before exiting. Paste the contents of the window here so we can take a look.

Also, if you can share the model, that might make things easier.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

What window are you refering to? Unfortunatly i cant share the model. Even if I try putting a "pause" at the beginning of the MDL.BAT I still get the same error.
The path to the comp folder is "C:\Program Files (x86)\Vensim\COMP\".
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

I think you've got the path to MDL.bat wrong. The instructions do say that the path to mdl.bat should be c:\Users\Public\Vensim\comp (or for older installations, “c:\program files\vensim\comp\”).

Try that and see what happens. Vensim is trying to call “c:\program files (x86)\vensim\comp\mdl.bat” on your machine, and I'm guessing you've been editing "c:\Users\Public\Vensim\comp\mdl.bat".
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: "Failed to compile the model (does not exist)"

Post by tomfid »

When I look at the paths in the script output pasted above, I see things like:

Code: Select all

C:\Program Files (x86)\Vensim\COMP>if exist mdl.obj del mdl.obj
It appears that this output is from manually running mdl.bat from the command line in the comp folder, not a Vensim-launched compile. That won't tell us anything, because mdl.c is not in \Vensim\COMP.

We need the output from the Vensim-launched mdl.bat window to properly diagnose this. It won't reveal anything about the model.
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

Thank you for your answers.
Administrator wrote:I think you've got the path to MDL.bat wrong. The instructions do say that the path to mdl.bat should be c:\Users\Public\Vensim\comp (or for older installations, “c:\program files\vensim\comp\”).

Try that and see what happens. Vensim is trying to call “c:\program files (x86)\vensim\comp\mdl.bat” on your machine, and I'm guessing you've been editing "c:\Users\Public\Vensim\comp\mdl.bat".
The path is definitly right. If I change the path to the COMP folder in VenSim to anything else, the error message specifically says "mdl.bat not found". The path "c:\Users\Public\Vensim\comp" does not exist on my computer and i am editing the mdl.bat file in "C:\Program Files (x86)\Vensim\COMP" which I also specific under options -> startup in vensim.

So there must be something wrong inside the mdl.bat. I will reinstall VisualStudio. Maybe the mdl.bat cant open "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat" for some reason or the vcvars32.bat causes the error. I will try that and get back to you. If you have any other ideas, I would be gratefull.

Thank you!
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

I suspect you originally did not install Vensim with admin permissions, that is why c:\users\public\vensim does not exist.

I'd suggest a re-install, this time using admin permissions. Then follow the instructions in the document I posted previously in this thread.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

Ok, I will try that. But why would that make a difference, if i can specifically tell VenSim where the mdl.bat is located anyway? So from my understanding it should not matter where the mdl.bat is as long as I put the right path in option->startup. Am I missing something?
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

Are you running MDL.BAT yourself?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

The output I posted earlier was from running it myself. Here's what happens when I try to run it from vensim (simulate the model):

Option 1: With a wrong path to mdl.bat I specifically get the error "couldnt find mdl.bat"
Option 2: With the right path (in my case C:\Program Files (x86)\Vensim\COMP) I right away get the error message "Failed to compile the model (does not exist)"

So I conclude that VenSim has found the mdl.bat but an error comes up right away.
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

The output I posted earlier was from running it myself. Here's what happens when I try to run it from vensim (simulate the model):
Don't do this, it will never work, this is what is causing all the confusion.

What we need is the output from when Vensim calls it. Edit your MDL.BAT file and comment out "@ECHO OFF". This will list all the commands as they happen. Make sure the last command in the batch file is "pause".

Now in Vensim, click Tools->Options->Advanced, and set the "Compilation" flags to "Query".

Now open a model, and click the simulate button. Vensim should ask you if you want to compile. Click Yes. Vensim creates mdl.c and then calls mdl.bat. The DOS window will appear and attempt to compile the model. Post the output from this so we can take a look.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

Yes I understand. I followed all you steps, but after I get asked if I want to compile and I click yes, I can see the DOS Window appear for a millisecond and then it disappears and the error from VenSim pops up ("failed tom compile the model (does not exist)"). So there is no chance for me to copy anything out of the DOS windows since I dont see anything myself. Do you think it might be because of the vcvars32.bat? Maybe theres an error in the VisualStudio files and thats why I dont even see the DOS windows anymore?


This is my mdl.bat, so you can see what I'm using:

REM @ECHO OFF
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
if exist mdl.obj del mdl.obj
if exist %3.dll del %3.dll
if .%2 == . goto noinclude
CL /O2 /c /I "%2" /DWIN32 mdl.c
goto aftercomp
:noinclude
CL /O2 /c /DWIN32 mdl.c
:aftercomp
if errorlevel 1 goto :error1
if not exist mdl.obj goto :error2
LINK /DLL /OUT:%3.dll /def:%1sim.def mdl.obj
if errorlevel 1 goto :error3
if not exist %3.dll goto :error3
REM clean up .lib and .exp files - they are not neaded
del %3.lib
del %3.exp
goto :exit
:error1
echo There were errors while compiling - check the paths in mdl.bat in vensim\comp
goto exit2
:error2
echo Unable to compile. You probably need to set paths in mdl.bat in vensim\comp
goto exit2
:error3
echo Errors while linking %3.dll - make sure compiled simulations were properly
installed
goto :exit2
:exit2
pause
goto :exit3
:exit
echo ----------
echo Compilation of %3 seems to have been successful.
echo Close this window and continue.
:exit3
pause
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: "Failed to compile the model (does not exist)"

Post by Administrator »

RWTH_FCN wrote: I can see the DOS Window appear for a millisecond and then it disappears
This indicates that the path to mdl.bat is not set correctly in Tools->Options->Startup.

Are you running double precision Vensim?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: "Failed to compile the model (does not exist)"

Post by RWTH_FCN »

No I'm running vensim.exe even though there also is a vensimdp.exe. Should I give that a try? How can the path not be set correctly if I edit and use the mdl.bat and then just copy the exact path in VenSim?
Post Reply