Install¤
msl-loadlib
is available for installation via the Python Package Index
pip install msl-loadlib
Optional dependencies¤
You can install msl-loadlib
and Python.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 is built into a frozen executable for Windows and Linux (glibc).
- You may also create a custom 32-bit server.
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 .NET library, you must install Python.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 environment variable. For example, the following should return the version of Java that is installed
> java -version
java version "23.0.2" 2025-01-21
Java(TM) SE Runtime Environment (build 23.0.2+7-58)
Java HotSpot(TM) 64-Bit Server VM (build 23.0.2+7-58, mixed mode, sharing)
If you need to load a Component Object Model or an ActiveX library you must install comtypes
pip install comtypes
Managing library dependencies
When loading a 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 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 Debian-based Linux distributions, the following packages are required. For other distributions, use the appropriate system package manager (e.g., yum) and the equivalent command.
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
. The dependencies for the C/C++ or FORTRAN library that you want to load may be different.
sudo dpkg --add-architecture i386
sudo apt update
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 .NET library then you must install Mono and Python.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
Tip
When loading a library it is vital that all dependencies of the library are also on the computer and that the directory that the dependency is located in is available on the PATH variable. A helpful utility to determine the dependencies of a library on Unix is ldd.
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.
Tip
It is recommended to update Homebrew before installing packages with brew update
To load a C/C++ or FORTRAN library install gcc (which includes gfortran)
brew install gcc
If you need to load a .NET library, you must install Mono,
brew install mono
and Python.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