Frequently Asked Questions


  1. I have the SNOPT source code. How do I get it going?

    A simple

    >> ./configure
    >> make install
    >> make examples

    will compile the package library and the included examples. See Compiling SNOPT for more information.

  2. I have the SNOPT libraries/mexfiles. How do I use them?

    See Linking to the SNOPT Library for more information.

Common errors

  1. Everything seems to compile correctly, but when I run an example or my own problem, I get the error: Fortran runtime error: Unit number in I/O statement too large. What’s wrong?

    This usually happens when there is a compatibility issue with the integers (32-bit vs 64-bit). If you are using the C/C++ interface, do not use 64-bit integers as that is not currently supported.

General SNOPT Question

  1. What is the largest number of variables and constraints that SNOPT can handle?

    The most important item is the “number of degrees of freedom” at the solution. An optimal basic solution for a linear program has 0 degrees of freedom. This is ideal: the solution is at a vertex of the constraint set. (We can take the constraints to be \(Ax = b, l \le x \le u\) without loss of generality, where \(A\) has \(m\) rows and \(n\) columns, \(m \lt n\).) There will be \(m\) basic variables with values between their bounds, and \(n-m\) nonbasic variables that are equal to one of their bounds.

    A nonlinear program will have some of the nonbasic variables strictly between their bounds. We call them superbasic variables, and they measure the number of degrees of freedom (or the distance from a vertex).

    SNOPT is “happy” if the number of superbasic variables is not more than a few hundred, because it prefers to work with a dense triangular matrix of that size. Even 2000 is fine – they just slow down accordingly. Subject to that, \(m\) and \(n\) can both be quite large – say 50,000 (but not millions!).

  2. SNOPT makes no progress and fails with the error message: ``EXIT 41 – the current point cannot be improved``. I can solve this problem successfully with another code. Is there a bug in SNOPT?

    This is most likely an error in the way that the constraints are defined. First, check the derivatives using the option “Verify level 3”. If the derivatives appear to be correct, take the solution found by the other program and make it the initial point for an SNOPT run. If the problem is defined correctly, SNOPT should terminate successfully at the initial point. (A number of minor iterations may be needed to identify the correct basis, but the number of major iterations should never be more than 1 or 2, depending on the accuracy of your solution). If SNOPT does a significant number of major iterations, the problems solved by the two codes are probably not the same.

  3. SNOPT makes no or slow progress, takes small steps, and/or doesn’t seem to be terminating. What can I do to improve SNOPT’s performance?

    First, check the derivatives that you have provided to SNOPT. Set the option “Verify level 3”. The print output file should have a list of all derivatives – any that appear to be incorrect are labeled as ‘bad?’ and the derivative implementation should be verified and corrected.

    If the specified derivatives are okay, it could be that the optimization hit the precision limit for your problem, i.e., it optimized as far as it could. Asking for too much accuracy is the usual explanation of this issue.

    The accuracy of the problem functions should be considered. In other words, what is the number of correct figures in the computed values of the objective and constraint values? For example, if the functions are computed by some iterative process such as an iterative method for solving a differential equation, then the precision will be related to the termination tolerance of the iterative method. The default value of the problem precision assumed by SNOPT is “Function precision 3.0e-13”, i.e., the assumption is that everything is computed to almost full accuracy.

    For more information, we recommend Chapters 7 and 8 of the book:

    AUTHOR = {Gill, Philip E. and Murray, Walter and Wright, Margaret H.},
    TITLE = {Practical Optimization},
    PUBLISHER = {Society for Industrial and Applied Mathematics},
    DOI = {10.1137/1.9781611975604},
    ADDRESS = {Philadelphia, PA},
    URL = {},
    EPRINT = {},
    YEAR = {2019}


  1. I tried to compile the Matlab mex-files on my Linux machine, but I get the error:

    /usr/bin/ld: ./lib/libsnmex7.a(snopta.o): relocation R_X86_64_32
    against ``.rodata' can not be used when making a shared object;
    recompile with -fPIC

    How do I fix this?

    Reconfigure the software package with --with-pic and then recompile. Also make sure to do a make veryclean before you compile again.

  2. I tried to use a precompiled Matlab mexfile on my Windows machine, but I get an error:

    Invalid MEX-file 'snoptmex.mexw32': The specified module could not be

    How do I fix this?

    This will happen if you don’t have all of the required runtime libraries. In particular, you should download and install the following redistributable libraries from Microsoft and Intel:

  3. When I try to use the precompiled Matlab mex-file,I get errors like:

    Invalid MEX-file ... : Missing dependent shared libraries: ''

    This happens if you do not have the gfortran compiler installed. Installing it will fix this issue.


  1. I’m using Visual Studio to compile SNOPT and its C+ interface but I get the following error: ``fatal error LNK1104: cannot open file ‘ifmodintr.lib’``. How do I fix this?

    Mixing Fortran with C/C++ requires some additional configuration in Visual Studio. Please see the following Intel article for more information Configuring Visual Studio for Mixed-Language Applications.

License Issues

  1. When I try to use SNOPT, I get an error saying I need a license. What do I do?

    Trial versions of SNOPT require a license file, which is attached to the email sent to you containing the download link. See License Setup for more information on how to set up your license.

Other Issues

  1. I want to use pyOptSparse, but it requires the source code for SNOPT. Can I use the SNOPT precompiled libraries with pyOptSparse?

    Yes, but you need to make a modification to pyOptSparse. The modification to the file pyoptsparse/pyoptsparse/pySNOPT/ is available here. You will need to appropriately define the location of the SNOPT library and re-build/install pyOptSparse. Make sure you have also set DYLD_LIBRARY_PATH (on macOS) or LD_LIBRARY_PATH (on Linux) to the location of the SNOPT library and also make sure to set up the SNOPT license.