libSBML C# API  5.18.0
Accessing libSBML from software

Once the libSBML files are installed, you may need to take additional steps so that software applications can find the libSBML library files at run time. This section provides information about how to do that.

1. Setting your library search path

Installing libSBML puts copies of the libSBML native object files in appropriate destinations on your computer. (By "native object files", we mean files such as libsbml.so, libsbml.5.dylib, libsbml.dll, etc.) On Mac OS X, this should be enough; a software application should be able to find the libSBML library file(s) when it runs. On Linux and Windows, that may not be enough to let a software application find the libSBML library files—you may need to take additional steps. This may be the case even if your application can find other libSBML components such as the language-specific interface (e.g., the libSBML JAR file in the Java case, or the libsbml.py file in the Python case).

If your run-time environment and the run-time environment for your software applications do not know to look in the directory where libSBML was installed, programs that require libSBML will fail to run and report errors about being unable to find libSBML.

How to configure most Linux platforms

There are two common approaches to solving the problem under Linux.

  1. Using ldconfig: Run the program ldconfig as user 'root' on your computer. (Please consult the man page for ldconfig if this is unfamiliar.) This will configure the system for all users.
  2. Setting environment variables: Ensure that each user sets the environment variable LD_LIBRARY_PATH in their terminal shells. If you downloaded a ready-to-run libSBML installer, the default where the libSBML library is installed is /usr/local/lib. If you built libSBML yourself using CMake, the path consists of /lib appended to the value used for the CMAKE_INSTALL_PREFIX configuration variable. If you built libSBML using GNU make, the path is DIR/lib, where DIR is the value used for the configuration option --prefix=DIR.

    For example, suppose you used the default installation prefix /usr/local/. Then in csh-based command shells under Linux, you may have to set the variable as follows (perhaps in your .cshrc file):

    setenv LD_LIBRARY_PATH /usr/local/lib
    

How to configure Microsoft Windows platforms:

Set the PATH environment variable to include the directory of the libSBML native library. To set an environmental variable in Windows, use the System option in the Windows Control Panel.

2. Importing libSBML

The C# interface for libSBML is implemented partly as pure C# and partly as native code. To use it in an application, an additional step must be performed after libSBML is installed and the your library search path is set as described above. The step is to place the managed library libsbmlcsP.dll into your application's directory.

C# applications need to be compiled by referencing the managed library libsbmlcsP.dll. This will also copy this managed library into the application's output directory. Once the managed library is referenced, and the native library can be found in the PATH (or, on Windows systems, if it is in the same directory as the executable), the C# bindings can be used in any .Net language program by simply including the libSBML namespace. The following C# code fragment illustrates how to use the namespace:

using namespace libsbml;