bullet

Compile Berkeley Spice 3F5 for Windows XP with Free Tools

bullet

Introduction

bullet
I wasn't able to find a WinXP compatible executable for Spice 3F5 anywhere.  So, I eventually figured out how to compile it myself...
bullet
I had a difficult time getting Spice to compile with newer Microsoft compilers.  It seems that it is rigged to compile with Microsoft Visual C 5.1, but I couldn't find that old program anywhere...  I found that I had to edit several files to produce a usable executable.
bullet
It took a few hours, but I was finally able to get it compiled and tested with some of the example circuit files.
bullet

You'll need:

bullet
The souce code file from Berkeley:  spice3f5.tar.gz (1.2Mb)
bullet
Trial version of Winzip to decompress the Berkeley source tarball  (Winzip is not free, but the trial version will do the job).
bullet
Free copy of Microsoft VC++ Express 2005 to compile the source
bullet

Instructions

bullet
First, download the source code using the link above.  If the link fails, try this page:  http://embedded.eecs.berkeley.edu/pubs/downloads/spice/index.htm , the origin of the link.
bullet
Next, unzip the file using Winzip.  Use the default settings so that the directory structure is preserved.  I unzipped to the folder "C:\Spice" so that everything was extracted to the "C:\Spice\spice3f5" folder.
bullet
We are going to compile from a "DOS" shell window, but we need to set the environment variables so that the OS can find the executable files required.  So, copy the environment setting batch file (C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat)  to the folder "C:\Spice\spice3f5\src".  This will let us save keystrokes when setting the environment...
bullet
Start a "DOS" shell window by clicking "Start->Run.." and then type in "cmd" in the dialog and then hit "OK".  You should then see a the black&white DOS shell window.  Type in "cd c:\spice\spice3f5\src" and hit "Enter" to get to the root folder.  Then, enter "vsvars32" to set the environment variables.
bullet
Now, if we had MS VC 5.1, then life would be very nice and all we would need to do is go to the "C:\Spice\spice3f5\src" folder and run "msc51.bat".  You can still try this if you want, to get an idea of how much work we need to do!  Just enter "msc51" at the DOS prompt and wait a minute or two as thousands of messages fly by...
bullet
If you look through the source, you will see that in every folder there is a "msc51.bat" file (for MS VC 5.1).  Apparently, MS has changed some of the syntax of the command line compiler since then, so we need to make a lot of changes.
bullet
One thing you need to know is that the output messages of the compiler are sent to the file "C:\Spice\spice3f5\src\msc.out".  You will need to check this file after every compile attempt to see what went wrong...  Use "Notepad" or "Wordpad" to view this file.
bullet
 If you ran "C:\Spice\spice3f5\src\msc51.bat", right now, you would create a "MSC.OUT" file with 798 kB of error messages.  The first messages deal with a problem in port.h
bullet
Open the file "C:\Spice\spice3f5\src\include\port.h" for editing.  If you just double-click on it from Explorer, Visual Studio should open the file for editing.  At the bottom of the file you will see this line "#ifndef CONFIGURED".  You need to comment out the error messages like this:

#ifndef CONFIGURED

//error error error error

//Operating system type unknown

//error error error error

#endif

  bullet

The next problem deals with the file "dev1.lib".  The compiler complains because it can't find the file.  My guess is that the 5.1 compiler would just create this output file if it couldn't find it, but newer compilers won't...  So, we must add the "/OUT:" directive to the batch file.  So, open "C:\Spice\spice3f5\src\lib\dev" and change the fifth line to this: 

lib /OUT:..\dev1.lib @response.lib >> ..\..\msc.out

bullet
You must also do this in subfolders "..\lib\dev\bjt" and "..\lib\dev\bsim1".
bullet
Now for some real work...  In "..\lib\dev" and in each of it's subfolders, you must edit the file, "response.lib", and remove all the "+", "&", and ";" characters.  For big files, I used the "replace" feature of Notepad to make this go a little faster...
bullet
At this point, we're half done so it's a good time to show some progress.  First, delete "C:\Spice\spice3f5\src\msc.out", then run "C:\Spice\spice3f5\src\lib\dev\msc51" from the DOS shell.  This will create the library files "..\lib\dev1.lib", "dev2.lib", and "dev3.lib".  If you check the msc.out file, you will find only warnings.
bullet
Next, in "..\lib\ckt", "..\lib\fte", "..\lib\hlp", "..\lib\inp", "..\lib\misc", "..\lib\ni", and "..\lib\sparse"  remove all the "+&;" characters from "response.lib" as before and also add the "/OUT:" to the last line in msc51.bat as before.
bullet
For "..\lib\cp" do the same as above and also in "..\src\include\cpstd.h" replace "_complex" with "my_complex"
bullet
In "..lib\sparse\spsmp.c" change all instances of "logb" to "_logb" and "scalb" to "_scalb".
bullet
At this point, we can check progress again.  Delete "msc.out" and run "C:\Spice\spice3f5\src\lib\msc51" in the command shell.  Check that all the ".lib" files have been created in the "..\src\lib" folder.  You can check "msc.out" for error messages.  Note that the "mfbpc" library won't compile because we don't have some add-in program that apparently isn't also public domain.  But, don't worry about it, we'll edit out the dependency later.
bullet
That's it for the "lib" folder.  Now, we just need a couple fixes in the "bin" folder.  We need to edit several files there with a ".lnk" extension.  Windows thinks they are shortcuts and won't let us edit them.  So, using the command prompt window, rename the files to have a ".link" extension.   Then, in "..\src\bin\msc51.bat" replace all instances of ".lnk" with ".link".
bullet
In "cspice.link", add "/OUT:" before "cspice.exe" and then remove the rest of this line.  Remove "/se:1000 /st:18000;" from the last line.  Remove the line containing "cspice.map".  Remove all "+" characters in the file.  Add ".lib" to the ends of all library file names.
bullet
Do the same thing for "bspice.link"
bullet
In "help.link", do the same and also remove "..\lib\mfbpc.lib" (because I can't figure out how to compile it, see above).  Same for "nutmeg.link", "sconvert.link", "proc2mod.link", and "makeidx.link"
bullet
Finally, compile everything by running "..\src\msc51.bat".

 

Bin\

            Using the command prompt, rename “*.lnk” to “*.link” so that windows will let you edit the files

            In cspice.link, add a space after “cspice.exe” and “/OUT:” before it.  Then remove the rest of this line.

                        Remove “/se:1000 /st:18000;” from the last line

            Remove the line with “cspice.map”

            Remove all the “+”s in the file

            Add “.lib” to the end of all the library file names

      Do the same thing for bspice.link

 

      In help.link, remove “..\lib\mfbpc.lib” because I couldn’t figure out how to compile it (see above).

      Same for nutmeg.link, sconvert.link, proc2mod.link, and makeidx.link