Building From Source

The LibStructural API library can be built on your machine from the source code found on github. To build LibStructural, you will need:

  • The LibStructural source code and dependencies from github (you will need git to clone/download the repo).
  • libSBML dependencies package. Make sure to get the vs15_release_x64 version.
  • libSBML version 5.15.0 source code. Get the “libSBML-5.15.0-core-src.zip” version.
  • CMake version 3.9.3 for generating solution files.
  • Visual Studio 2017 for Windows or Xcode for MacOS
  • Python 2.7 for generating a python wrapper (optional)
  • SWIG for generating python wrappers in Windows (optional).

NOTE: We provide libSBML and CLAPACK dependency libraries with our repo for both Mac and Windows. If you wish to build your own libSBML or CLAPACK dependency libraries follow the instructions on “Building libSBML” and “Building CLAPACK” sections.

Windows

First, clone/download the Libstructural source code from the github repo by running the following command from the command line or git software:

git clone https://github.com/yosefmaru/Libstructural

Prior to building LibStructural on Windows, binaries for libSBML needs to be generated first. To do this you, will need a libSBML dependencies package and source code. An issue on Windows concerns the dependency libraries on which libSBML depends. CMake will try to find all the dependencies for the default options, which leads to problems if they do not exist.

  1. Extract the dependencies folder you downloaded into the same folder where you unpacked the libSBML source distribution. CMake will look for these dependencies in a folder called “dependencies” directly below the libSBML root folder.
  2. rename the extracted libsbml dependencies folder from it’s default name to “dependencies”.
_images/libSBML_dependencies.JPG
  1. Once you have the libSBML sources and the dependency libraries unpacked on your system, start up the CMake graphical user interface (GUI).

Building libSBML

A detailed step-by-step instruction can be found on this link on how to generate a solution file using CMake and build libSBML libraries on Visual Studio.

  1. To be consistent with building LibStructural instructions, make sure to select “Visual Studio 15 2017 Win64” when selecting a generator on CMake.
  2. Copy the directory inside “Where is the source code” inquiry to the CMAKE_INSTALL_PREFIX option and add “/libsbml-vs2017-release-64” to it as shown below.
_images/libsbml_install_prefix.JPG
  1. After generating the solution file make sure you build with a Release configuration, instead of Debug configuration on visual studio.
  2. Build the solution file from the “INSTALL” target (i.e. on Visual Studio, right click on “INSTALL” and select Build). This target will install the compiled binaries to the directory specified on the CMAKE_INSTALL_PREFIX option, which is “…/libsbml-vs2017-release-64”
_images/libsbml_install.JPG
  1. Once you complete building libSBML, copy the libsbml-vs2017-release-64 folder to “…Libstructural/dependencies” that you cloned/downloaded from github. This step is very important since the LibStructural CMakeLists configuration that generates the solution file looks for libSBML libraries inside a folder named “libsbml-vs2017-release-64”. Thus, you should have “libsbml-vs2017-release-64” and “third-party” folders under dependencies.
_images/libstructural_dependencies.JPG

The next step is building LibStructural.

Building LibStructural

  1. Open CMake-gui.
  2. Click on the Browse Source… button and navigate to the directory where you cloned/downloaded the LibStructural folder on your file system.
  3. For the “Where to build the binaries” inquiry, use the same directory, but add /BUILD_x64 to it.
  4. On the CMake-gui click on Configure. A prompt will ask you to create a “BUILD_x64” folder inside LibStructural. Click on Yes.
  5. Next, it will ask you to specify a generator for the project and what compiler to use as shown below. For the generator, select “Visual Studio 15 2017 Win64”.
  6. Select “Use default native compilers” option and click on Finish.
_images/cmake_2.JPG
  1. If you wish to generate a python wrapper, you will have to checkmark the “ENABLE_PYTHON_WRAPPER” option.
  2. Click on Configure again and an error will appear in red on the top, asking for the location of a SWIG executable file.
  3. Click on the “SWIG_EXECUTABLE-NOTFOUND” and copy or navigate to the swig.exe directory. The swig.exe file will be in the SWIG folder you downloaded.

10. Click on Generate, and a LibStructural.sln file will be stored inside the BUILD_x64 folder. NOTE: If you don’t want to generate a python wrapper, simply click Configure and then Generate after step 2.

_images/cmake_SWIG_exe.JPG
  1. To build the libraries, open the solution file “LibStructural.sln” located in BUILD_x64 folder using Visual Studio 2017.
  2. On Visual Studio, set the build target to “Release” instead of “Debug” with “x64” configuration.
  3. Right click on ALL_BUILD and click on Build.

The built libraries and binaries will be stored in “…/BUILD_x64/LibStructural/Release” directory. If you chose to generate a python wrapper, it will be located inside INSTALL_x64/wrapper/structural.

Mac

For Mac, you will have to generate CLAPACK libraries in addition to libSBML. You need to generate MacOS compatible dependency libraries needed for building LibStructural. The CLAPACK source code is included in the LibStructural distribution that is cloned/downloaded from github. It is located inside the directory “…Libstructural/dependencies/third-party”. However, the libSBML source code is the one you should download from sourceforge.

Building CLAPACK

  1. Open CMake-gui.
  2. Click on the Browse Source… button and navigate to “…/dependencies/third-party/clapack/3.2.1” inside the Libstructural folder you cloned/downloaded.
  3. For the “Where to build the binaries” inquiry, use the same directory, but add /BUILD_x64 to it as shown below.
_images/cmake_xcode_1.png
  1. Click on Configure. CMake will ask for what generator and compiler to use.
  2. Find and select “Xcode” from the dropdown menu.
  3. Select “Specify native compilers” and click on Continue.
  4. On the next window, under C++ box, click on the three dots and navigate to your Xcode application. It should be located inside the Applications folder. If not, you need to move it to the Application folder. Click on Done.
  5. Click on Configure and then **Generate.
_images/cmake_xcode_2.png
_images/cmake_xcode_compilers.png
  1. Your Xcode project file will be generated inside “BUILD_x64” folder, or you can simply click on Open Project on CMake to automatically launch the project in Xcode.
  2. Once Xcode finishes loading/indexing the project, go to Product -> Scheme -> Edit Scheme (keyboard shortcut: Command + Shift + <). You will need to set the Build Configuration to “Release”.
_images/xcode_scheme.png
  1. Click on Product -> Build or the Play button.
  2. The libraries will be stored inside BUILD_x64. There are three libraries you will need to locate:
  • libblas.a which will be found in the directory “…/BUILD_x64/BLAS/SRC/Release”.
  • libf2c.a which will be found in the directory “…/BUILD_x64/F2CLIBS/libf2c/Release”.
  • liblapack.a inside “…/BUILD_x64/SRC/Release”.
  1. Copy these three libraries to “…/Libstructural/dependencies/third-party/clapack/3.2.1/LIB”.

Building libSBML

You will use the same steps as shown above with minor changes. Your source code is a libSBML package you downloaded from sourceforge.

  1. On CMake, locate the folder to fill “Where is the source” inquiry (i.e. “…/Downloads/libsbml-5.15.0”). Then click on Browse Build…* and use the same folder directory, but add “/BUILD_x64” to it. Click on **Configure
  2. Before generating the project file, copy the directory inside “Where is the source code” inquiry to the CMAKE_INSTALL_PREFIX option and add “/libsbml-vs2017-release-64” to it.
  3. Click on Configure then Generate.
  4. Open the Xcode project generated and go to Product -> Scheme to select “install”.
  5. Go to Product -> Scheme -> Edit Scheme (keyboard shortcut: Command + Shift + <). You will need to set the Build Configuration to “Release”.
  6. Click on Product -> Build or the Play button (keyboard shortcut: Command + B).
  7. After building succeeds, a “libsbml-vs2017-release-64”” folder will be created inside “…/libsbml-5.15.0”. Copy this folder in to “…/Libstructural/dependencies” directory. This step is very important since the LibStructural CMakeLists configuration that generates the Xcode project file looks for libSBML libraries inside a folder named “libsbml-vs2017-release-64”.

Building LibStructural

  1. Open CMake-gui. For the “Where is the source code” inquiry, click on Browse Source and navigate to the directory where LibStructural is located at. For the “Where to build the binaries” inquiry, use the same directory, but add “/BUILD_x64” to it.
  2. Follow steps 4-7 from the “Building CLAPACK” section.
  3. If you chose to build a python wrapper, checkmark the “ENABLE_PYTHON_WRAPPER” value and configure again. If no errors are raised click on Generate. Note: You don’t need to download SWIG as it is included in with your Mac OS.
  4. Follow step three from the “Building CLAPACK” section.
  5. Once Xcode finishes loading/indexing the project, go to Product -> Scheme -> Edit Scheme (keyboard shortcut: Command + Shift + <). You will need to set the Build Configuration to “Release”. If you chose to generate python wrapper from step three, go to Product -> Scheme and select “install”. Otherwise, click on Product -> Build or the Play button (keyboard shortcut: Command + B).
  6. The built libraries and binaries will be stored in “…/BUILD_x64/LibStructural/Release” directory. If you chose to generate a python wrapper, the wrapper will be stored inside “…/INSTALL_x64/wrapper/structural”.