Hi,
I'm trying to learn how to compile simulations, and ultimately build a .exe file that utilizes the .dll to provide a commercial friendly interface.
I am new to all of this, so I started by trying to compile a simulation using the options> setup command within Vensim. When I click simulate, the DOS window opens and eventually pauses on a line that lists the directory where the model is located. It says press any key to continue. If I do, I get an error that says "Failed to compile the model (does not exist)."
In the background, prior to clicking a button on DOS to continue, Vensim has a box open that reads "compiling model equations....." where the ..... are still in motion. Do I just need to be patient and let Vensim do its thing or does the fact that the DOS window pauses signal that there is an error?
I have Bloodshed C++ installed on my system. Even after this is all finished (error and everything), I do get a file called mdl.c which opens bloodshed. Obviously, the file does not work. I'd appreciate any insights.
Thanks
Compiling
-
- Super Administrator
- Posts: 4835
- Joined: Wed Mar 05, 2003 3:10 am
When you set Vensim to compile models, it creates a DLL that contains all the calculations usually done by Vensim itself. This speeds up model simulation time.
The DOS window is actually calling the compiler, you should leave it until it finishes. MDL.C is the actual code for the model, if you look into it you will see functions that compute the rates, levels etc.
I have no experience of Bloodshed C++ but I am fairly certain that you will need to set it up yourself to create the DLL. MDL.BAT is geared towards the Microsoft compilers. You might try the express versions if you don't have a full copy of Microsoft Developer Studio.
http://msdn.microsoft.com/vstudio/express/
Tony.
The DOS window is actually calling the compiler, you should leave it until it finishes. MDL.C is the actual code for the model, if you look into it you will see functions that compute the rates, levels etc.
I have no experience of Bloodshed C++ but I am fairly certain that you will need to set it up yourself to create the DLL. MDL.BAT is geared towards the Microsoft compilers. You might try the express versions if you don't have a full copy of Microsoft Developer Studio.
http://msdn.microsoft.com/vstudio/express/
Tony.
Tony,
Thanks. I installed the express version for microsoft and now I'm getting an error in the DOS window that reads :
There were errors while compiling - check the paths in mdl.bat in vensim\comp.
So, I found this in Ch 10 of the Vensim Help Menu:
The file mdl.bat controls the compilation process. The most common problem with this file is that the simulation paths have not been properly set. At the very top of this file we recommend that you explicitly set the compilation paths with commands such as:
path = "c:\Program Files\Microsoft Visual Studio\VC98\bin;"c:\Program Files\Microsoft Visual Studio\common\MsDev98\bin"
set LIB=c:\Program Files\Microsoft Visual Studio\vc98\lib
set INCLUDE=c:\Program Files\Microsoft Visual Studio\vc98\include
The first two lines must actually appear on a single line. Microsoft Visual C/C++ version 5 and later require two bin directories to be included in the Path statement. Earlier versions required only 1.
The default mdl.bat that ships with Vensim has the above path, lib, and include statements, as well as commented out versions of these for earlier compilers. If you installed your compiler into a different directory or drive you will need to make adjustments to the above statements. If you make changes to mdl.bat an original version of this file is kept in mdlorig.bat.
NOTE If you are using Windows NT don't put quotes in the path name. The mdl.bat file that ships with Vensim tests for Windows NT and should work on both Windows NT/2000/XP and Windows 95/98/Millennium.
------
Well, first of all, I'm using a newer version of Microsoft Visual (Version
so I think the paths are quite a bit different. I tried my best to edit the mdl.bat file in wordpad by directing it to the right paths, but still getting the same error.
Thanks for any help.
Thanks. I installed the express version for microsoft and now I'm getting an error in the DOS window that reads :
There were errors while compiling - check the paths in mdl.bat in vensim\comp.
So, I found this in Ch 10 of the Vensim Help Menu:
The file mdl.bat controls the compilation process. The most common problem with this file is that the simulation paths have not been properly set. At the very top of this file we recommend that you explicitly set the compilation paths with commands such as:
path = "c:\Program Files\Microsoft Visual Studio\VC98\bin;"c:\Program Files\Microsoft Visual Studio\common\MsDev98\bin"
set LIB=c:\Program Files\Microsoft Visual Studio\vc98\lib
set INCLUDE=c:\Program Files\Microsoft Visual Studio\vc98\include
The first two lines must actually appear on a single line. Microsoft Visual C/C++ version 5 and later require two bin directories to be included in the Path statement. Earlier versions required only 1.
The default mdl.bat that ships with Vensim has the above path, lib, and include statements, as well as commented out versions of these for earlier compilers. If you installed your compiler into a different directory or drive you will need to make adjustments to the above statements. If you make changes to mdl.bat an original version of this file is kept in mdlorig.bat.
NOTE If you are using Windows NT don't put quotes in the path name. The mdl.bat file that ships with Vensim tests for Windows NT and should work on both Windows NT/2000/XP and Windows 95/98/Millennium.
------
Well, first of all, I'm using a newer version of Microsoft Visual (Version

Thanks for any help.
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
I am including below what you will need to include in mdl.bat to get it to work with the express compiler. to recompile simext.c just open a DOS window wherever mdl.bat is, execute mdl.bat to set the paths (it will give an error message) then execute the C command
CL /c /O2 simext.c
Note however that none of this is taking you in the direction you want to go. If you want to provide people with a model you can publish it, create a Venapp, use Sable or use the Vensim DLL with your choice of development environments. All that compiling does is decrease the time required to simulate a model.
Bob Eberlein
set PATH=c:\Program Files\Microsoft Visual Studio 8\Common7\IDE;c:\Program Files\Microsoft Visual Studio 8\VC\bin
set LIB=c:\Program Files\Microsoft Visual Studio 8\vc\lib
set INCLUDE=c:\Program Files\Microsoft Visual Studio 8\vc\include
REM Note - if you are using Visual C++ 2005 Express Edition you will need to
REM recompile simext.c use the command lines
REM CL /c /O2 simext.c
CL /c /O2 simext.c
Note however that none of this is taking you in the direction you want to go. If you want to provide people with a model you can publish it, create a Venapp, use Sable or use the Vensim DLL with your choice of development environments. All that compiling does is decrease the time required to simulate a model.
Bob Eberlein
set PATH=c:\Program Files\Microsoft Visual Studio 8\Common7\IDE;c:\Program Files\Microsoft Visual Studio 8\VC\bin
set LIB=c:\Program Files\Microsoft Visual Studio 8\vc\lib
set INCLUDE=c:\Program Files\Microsoft Visual Studio 8\vc\include
REM Note - if you are using Visual C++ 2005 Express Edition you will need to
REM recompile simext.c use the command lines
REM CL /c /O2 simext.c
-
- Super Administrator
- Posts: 4835
- Joined: Wed Mar 05, 2003 3:10 am