Most issues are linked with either the calling program (such as AMPL or MATLAB) not finding the Knitro binaries, or with Knitro not finding the license file. These are discussed first.
Below is a list of steps to take if you have difficulties installing Knitro.
Create an environment variable
ARTELYS_LICENSE_DEBUGand set it to 1. This will enable some debug output printing that will indicate where the license manager is looking for a license file. See Section 4.1 of the Artelys License Manager User’s Manual for more details on how to set the
ARTELYS_LICENSE_DEBUGenvironment variable and generate debugging information.
Ensure that the user has the correct permissions for read access to all libraries and to the license file.
Ensure that the program calling Knitro is 32-bit (or 64-bit) when Knitro is 32-bit (or 64-bit). As an example, you cannot use Knitro 32-bit with MATLAB 64-bit or vice versa. This applies to the Java Virtual Machine and Python as well.
On Windows, make sure that you are setting system environment variables rather than user environment variables, when setting environment variables for Knitro (or, if using user environment variables, that the correct user is logged in).
Knitro has multiple options for installing license files. If the procedure you are trying is not working, please try an alternative procedure.
If you have multiple Knitro executable files or libraries of the same name on your computer, make sure that the one being used is really the one you intend to use (by making sure it appears first in the definition of the appropriate environment variable).
Please also refer to the Artelys License Manager User’s Manual provided with your distribution for additional installation and troubleshooting information.
Below are some troubleshooting tips specific to the Knitro/MATLAB interface.
Make sure the Knitro/MATLAB interface files
knitro_*.p, etc., are located in a folder/directory where they can be found by your MATLAB session. See Installation for more information on adding the Knitro/MATLAB interface files to your MATLAB path.
To use Knitro with older versions of MATLAB (i.e. pre-2018) on Linux-based systems, it may be necessary to first set the
LD_PRELOADenvironment variable to point to the
libiomp5.soshared library provided in the Knitro
libdirectory, before starting MATLAB from the command line. For example:
On Mac OS X, if Knitro/MATLAB is not finding the license file (or a library), try starting MATLAB from the Terminal by typing “matlab” from a Terminal window. Sometimes environment variables are not inherited properly by a MATLAB session on Mac OS X when the session is started by double-clicking on the MATLAB icon.
If you encounter the error message cannot load any more object with static TLS this is a MATLAB bug (bug# 961964) on Linux. You may try one of the following workaround, if the issue remains, you may contact Mathworks directly.
Insert ones(10)*ones(10); in the file
Preload any library before starting MATLAB using the environment variable
Run MATLAB without the GUI by running the following command from a terminal
Symbolic links, on systems that support them, are an alternative to copying / renaming the file.
Python interface issues
If you are using the Python interface on a Linux or Unix platform, you may need to use a Python distribution that has been compiled with the -fopenmp flag of the gcc/g++ compiler in order to use the standard Knitro libraries. Otherwise, you should use the sequential Knitro libraries. See Linux and Mac OS X compatibility issues for more information.
Issues opening Knitro files on MacOS
On MacOS, when using a Knitro library or binary for the first time, you may receive a security warning that prevents you from opening the binary or library, for example:
knitroampl cannot be opened because developer cannot be verified.
In this case you can follow the steps below to open/use the file. Note that this is only necessary the first time you try to open/use the particular file.
Traverse through to the appropriate Knitro distribution folder containing the file
Highlight the binary or library file that produces the message above
Right “Click” & Select “Open”
Issues using OpenMP in Knitro on MacOS
The Knitro software uses OpenMP for multi-threading and provides a dynamic OpenMP library (
libomp.dylib) in the
lib folder in the Knitro distribution for MacOS machines with M1 processors.
However, the first time you try to use Knitro, you may
receive a security warning:
“libomp.dylib” can’t be opened because Apple cannot check it for malicious software. This software needs to be updated. Contact the developer for more information
You may try the following steps to workaround this security issue:
Traverse through to the Knitro distribution
libomp.dylibfile that produces the message above
Right “Click” & Select “Open”
You may also try to download and install your own libomp library file using the MacOS homebrew utility. After installing homebrew, at the terminal run the command: brew install libomp.
Loading external third party dynamic libraries
Some user options instruct Knitro to load dynamic libraries at runtime.
This will not work unless the executable can find the desired library using the
operating system’s load path. Usually this is done by appending the
path to the directory that contains the library to an environment variable.
For example, suppose the library to be loaded is in the Knitro
directory. The instructions below will correctly modify the load path.
On Windows, type (assuming Knitro 13.1.0 is installed at its default location):
set PATH=C:\Program Files\Artelys\knitro-|release|-z\lib;%PATH%
On Mac OS X, type (assuming Knitro 13.1.0 is installed at /tmp):
If you run a Unix bash shell, then type (assuming Knitro 13.1.0 is installed at /tmp):
If you run a Unix csh or tcsh shell, then type (assuming Knitro 13.1.0 is installed at /tmp):
setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:/tmp/knitro-|release|-z/lib
Linux and Mac OS X compatibility issues
Linux platforms sometimes generate link errors when building the programs
examples/C. Simply type “gmake” and see if the
build is successful. You may see a long list of link errors similar to the
../lib/libknitro.a(.text+0x28808): In function `ktr_xeb4': : undefined reference to `std::__default_alloc_template<true, 0>::deallo cate(void*, unsigned int)' ../lib/libknitro.a(.text+0x28837): In function `ktr_xeb4': : undefined reference to `std::__default_alloc_template<true, 0>::deallo cate(void*, unsigned int)' ../lib/libknitro.a(.text+0x290b0): more undefined references to `std::__ default_alloc_template<true, 0>::deallocate(void*, unsigned int)' follow ../lib/libknitro.a(.text+0x2a0ff): In function `ktr_x1150': : undefined reference to `std::basic_string<char, std::char_traits<char> , std::allocator<char> >::_S_empty_rep_storage' ../lib/libknitro.a(.text+0x2a283): In function `ktr_x1150': : undefined reference to `std::__default_alloc_template<true, 0>::deallo cate(void*, unsigned int)'
This indicates an incompatibility between the libstdc++ library on your Linux distribution and the library that Knitro was built with. The incompatibilities may be caused by name-mangling differences between versions of the gcc/g++ compiler, and by differences in the Application Binary Interface of the two Linux distributions. The best fix is for Artelys to rebuild the Knitro binaries on the same Linux distribution of your target machine (matching the Linux brand and release, and the gcc/g++ compiler versions).
Other link errors may be seen on 64-bit Linux and Mac OS X platforms related to undefined references to “omp” or “pthread” symbols. For example, the link errors may look something like
undefined reference to `pthread_setaffinity_np@GLIBC_2.3.4'
on Linux, or
Undefined symbols: "_GOMP_parallel_start", referenced from:
on Mac OS X.
This implies either that the dynamic libraries needed for OpenMP
(usually provided in system directories, or in the Knitro
directory for the Mac OS X distribution) are not being found,
or that the version of gcc/g++ used for linking is not
compatible with the OpenMP features used in the standard Knitro 13.1 libraries.
To solve this issue, be sure that the
DYLD_LIBRARY_PATH on Mac OS X)
environment variable includes the Knitro
or try linking against the sequential versions of the Knitro libraries
provided with your platform distribution on Linux. See the
README file provided
in the Knitro
lib directory for more information
Windows compatibility issues
Using the “dll” version of the Knitro library on Windows (i.e. linking against
is recommended and should be compatible across multiple versions of the Microsoft Visual C++ (MSVC)