=================
BUILD PROCEDURES:
=================

Step by step instructions for building
snopt.lib and snoptcmex.mexw32 on win32 systems.
Written December 16, 2010
Thanks to: Philip Freeman, The Boeing Company, St. Louis
           mailto:philip.l.freeman@boeing.com

The instructions are written using Microsoft Visual C++ 2008 Express
Edition.

Microsoft has a tendancy to change their IDE's interface from time to
time.  However, the basic steps and requirements should stay about the
same, you might jsut have to fiddle to find the menus and options.

The directories can be whatever you want, but for clarity I
have installed libf2c into c:\libf2c and SNOPT into c:\snopt7

*** Building vcf2c.lib ***
1) Dowload libf2c.zip from http://www.netlib.org/f2c/

2) Unzip archive into C:\libf2c

3) Start Visual Studio

4) Open a Visual Studio command prompt. You should be able to
        find this under the Tools menu.

5) From the command prompt issue the following commands
        cd c:\libf2c
        nmake -f makefile.vc
        exit

At this point, you should now have the file vcf2c.lib in the
directory c:\libf2c.

6) Unzip the SNOPT sources into the directory c:\snopt7

7) Copy the file c:\libf2c\vcf2c.lib into c:\snopt7\win32
        Answer Yes to overwrite the existing file.

8) From Visual Studio, select File->Open->Project/Solution.
        Open c:\snopt7\win32\snoptcmex\snoptcmex.sln

9) Visual Studio will probably ask about converting the solution file.
        If it does, that is no problem. Simply select Next, Next, Finish,
        Close.

The solution has two projects. It is easiest (in my opinion) if you
build them one-by-one rather than the whole solution at once. First,
we will build the snopt project.

*** Building snopt.lib ***
10) Right click on the snopt project and choose Build.

This will produce several warnings, but should succeed.

*** Building snoptcmex.lib ***
11) Right click on the snoptcmex project, and choose properties.

12) Under Configuration Properties; C/C++:General
        add the path to the Matlab include directories to the entry for
        "Additional Include Directories" (add as a new line).
        In my case, this was
        C:\Program Files\Matlab\R2010a\extern\include\

13) Under Configuration Properties; Linker:General
        add the path to your compiler specific Matlab mex libraries.
        In my case, this was
        C:\Program Files\Matlab\R2010a\extern\lib\win32\microsoft\

14) Under Configuration Properties; Linker:Input remove the entry
        LIBCMT.lib from Ignore Specific Library

15) Click on the OK button to save the project changes.

This will produce several warnings, but should succeed. At this
point you should now have a new snoptcmex.dll file in the directory
c:\snopt7\matlab\


16) Right click on the snoptcmex project and choose Build.

    It may be necessary to do the following:

    (16a) Remove the resource reference in snoptcmex project.
           Right click on the Resources folder and delete it
           Project->Properties: under Configuration Properties: Resources:General
           Delete the entry for the resource file name.
    (16b) Change the runtime library to /MT
           Project->Properties: under Configuration Properties: C/C++:Code Generation
           Change the entry Runtime Library to /MT

17) Rename snoptcmex.dll to snoptcmex.mexw32

18) While everything should be OK. If you have dependency walker, it is
        a good idea to open snoptcmex.mexw32 with depends.exe and double
        check that all dependencies are found (except MSJAVA.dll, which it is
        okay not to have). Depends.exe should also show a single C-function
        entry point named mexFunction.

19) Copy the contents of c:\snopt7\matlab into $localToolboxes$\snopt, where
        $localToolboxes$ is wherever you like to keep your Matlab toolboxes.

*** Now, we are ready to test the build ***
20) Start Matlab.

21) (This may not be necessary, but I can't recall all of what gets cached)
        If you are updating from a previous version of snopt, you may want
        to clear out the toolbox cache. The Matlab help gives instructions for
        how to do this. On my version of Matlab it is
        File->Preferences, then click on the button Update Toolbox Path Cache.

21) Change to $localToolboxes$\snopt

22) From the Matlab command prompt
        runAllExamples

All the examples should work, and the directory to the snoptcmex file
should now be added to the Matlab path.


========Add paths to the Matlab include and library directories====

 1)  Open Microsoft Visual C++.
 2)  Click on "Tools" and choose "Options...".
 3)  Click on "Projects"
 4)  Click on "VC++ Directories"
 4)  Under "Show directories for",  choose "Include files".
 5)  Add MATLAB\EXTERN\INCLUDE.  Here MATLAB denotes the location
     of the user's matlab package.

       Example: C:\Program Files\MATLAB704\extern\include

 6)  Under "Show directories for",  choose "Library files".
 7)  Add the location of Microsoft Visual C++ mex libraries.

       Example: C:\Program Files\MATLAB704\extern\lib\microsoft\msvc71

 8)  Click "OK".

======================Open snoptcmex project=======================

 9)  Click on "File" and choose "Open Solution".
10)  Choose project file:
        snopt7/win32/snoptcmex/snoptcmex.sln
11)  Click "Open".

=======================Build snoptcmex.dll=========================

9) Click (at the top) on "Build".  Choose Build "snoptcmex" or
   "Rebuild All".
10) This should place a copy of snoptcmex.dll inside the folder

       snopt7/matlab

===============
RUN PROCEDURES:
===============

(see the help files in the directory snopt7/matlab)
