Install
To install msl-loadlib run
pip install msl-loadlib
Alternatively, using the MSL Package Manager run
msl install loadlib
Dependencies
Python 3.8+
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 32-bit server has been built into a frozen Python executable for Windows and Linux.
You may create a new 32-bit server. See Create a custom 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 32-bit 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, you must install Python for .NET
pip install pythonnet
If you need to load a Java library (i.e., a .jar
or .class
file),
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 22 2024-03-19
Java(TM) SE Runtime Environment (build 22+36-2370)
Java HotSpot(TM) 64-Bit Server VM (build 22+36-2370, mixed mode, sharing)
If you need to load a Component Object Model (or ActiveX) library, 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 (and possibly you may need
to add a directory with os.add_dll_directory()
). 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 may also be helpful.
Linux
Before using msl-loadlib on Linux (Debian), the following packages are required. For other linux distributions, use the appropriate system package manager (e.g., yum) and the equivalent command.
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.
Install the packages that are required to load 32-bit and 64-bit C/C++ and FORTRAN libraries
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
Important
As of version 0.10.0 of msl-loadlib, pythonnet is no longer installed
on the 32-bit server for Linux. Mono can load both 32-bit and 64-bit
libraries on 64-bit Linux 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),
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, you must install Mono,
brew install mono
and Python for .NET
pip3 install pythonnet
If you need to load a Java library (i.e., a .jar
or .class
file),
you must install Py4J,
pip3 install py4j
and a Java Runtime Environment
brew cask install java