Install
To install MSL-LoadLib run
pip install msl-loadlib
Alternatively, using the MSL Package Manager run
msl install loadlib
Dependencies
Python 2.7, 3.5+
Optional dependencies:
You can install MSL-LoadLib and Python for .NET using,
pip install msl-loadlib[clr]
MSL-LoadLib and Py4J,
pip install msl-loadlib[java]
MSL-LoadLib and comtypes,
pip install msl-loadlib[com]
or MSL-LoadLib and all optional dependencies
pip install msl-loadlib[all]
Compatibility
The
start_server32
module has been built into a frozen Python executable for Windows and Linux and works with the Python versions listed above. The 32-bit server is running on a Python 3 interpreter and therefore all modules that run on the server must use Python 3 syntax.You can create a new 32-bit server. See Re-freezing the 32-bit server for more details.
Prerequisites
Windows
64-bit Windows already comes with WoW64 to run 32-bit software and therefore
no prerequisites are required to load __cdecl
or __stdcall
libraries.
However, the library might have its own dependencies, such as a particular
Visual C++ Redistributable, that may need to be installed.
If you need to load a Microsoft .NET library then you must install Python for .NET
pip install pythonnet
If you need to load a Java library (i.e., a .jar
or .class
file)
then you must install Py4J,
pip install py4j
a Java Runtime Environment, and ensure that the java
executable
is available on the PATH variable. For example, the following should return the
version of Java that is installed
C:\Users\username>java --version
java 19 2022-09-20
Java(TM) SE Runtime Environment (build 19+36-2238)
Java HotSpot(TM) 64-Bit Server VM (build 19+36-2238, mixed mode, sharing)
If you need to load a Component Object Model library then you must install comtypes
pip install comtypes
Tip
When loading a shared library it is vital that all dependencies of the library are also on the computer and that the directory that the dependencies are located in is available on the PATH variable. A helpful utility to determine the dependencies of a shared library on Windows is Dependencies (which is a modern Dependency Walker). Microsoft also provides the DUMPBIN tool. For finding the dependencies of a .NET library the Dependency Walker for .NET can also be helpful.
Linux
Before using MSL-LoadLib on Linux, the following packages are required.
Install the packages that are required to load 32-bit and 64-bit C/C++ and FORTRAN libraries
Attention
The following packages are required to run the examples that are included with MSL-LoadLib when it is installed. The dependencies for the C/C++ or FORTRAN library that you want to load may be different.
sudo apt install g++ gfortran libgfortran5 zlib1g:i386 libstdc++6:i386 libgfortran5:i386
The following ensures that the ss command is available
sudo apt install iproute2
If you need to load a Microsoft .NET library then you must install Mono (see here for instructions) and Python for .NET
pip3 install pythonnet
Attention
If your version of Python is < 3.7, wheels for pythonnet are not available on PyPI and you must build Python for .NET from source. First, install the build dependencies,
sudo apt install libglib2.0-dev clang python3-pip python3-dev
pip3 install pycparser
and then install Python for .NET
pip3 install pythonnet
If you have problems installing Python for .NET then the best place to find help is on the issues page of Python for .NET's repository.
Important
As of version 0.10.0 of MSL-LoadLib, pythonnet is no longer available
on the 32-bit server for Linux. Mono can load both 32-bit and 64-bit
libraries and therefore a 32-bit .NET library can be loaded directly
via LoadLibrary
on 64-bit Linux.
If you need to load a Java library (i.e., a .jar
or .class
file)
then you must install Py4J,
pip3 install py4j
and a Java Runtime Environment
sudo apt install default-jre
macOS
The 32-bit server has not been created for macOS; however, the
LoadLibrary
class can be used to load a
library that uses the __cdecl
calling convention that is the same
bitness as the Python interpreter, a .NET library or a Java library.
The following assumes that you are using Homebrew as your package manager.
It is recommended to update Homebrew before installing packages
brew update
To load a C/C++ or FORTRAN library install gcc (which includes gfortran)
brew install gcc
If you need to load a Microsoft .NET library then you must install Mono,
brew install mono
and Python for .NET
pip3 install pythonnet
Attention
If your version of Python is < 3.7, wheels for pythonnet are not available on PyPI and you must build Python for .NET from source. First, install the build dependencies,
brew install pkg-config glib
pip3 install pycparser
and then install Python for .NET
pip3 install pythonnet
If you have problems installing Python for .NET then the best place to find help is on the issues page of Python for .NET's repository.
If you need to load a Java library (i.e., a .jar
or .class
file)
then you must install Py4J,
pip3 install py4j
and a Java Runtime Environment
brew cask install java