Skip to content

Discussion: Resolving DLL Import Errors for libtorrent on Windows #7978

@a-sajjad72

Description

@a-sajjad72

Background

There are multiple open issues in the repository regarding DLL import errors on Windows when using the Python bindings. These errors primarily arise due to missing OpenSSL DLLs (libcrypto-1_1-x64.dll and libssl-1_1-x64.dll) or incorrect side-by-side configuration.

Current Issues

Below are the related issues:

Proposal

This discussion aims to resolve these errors systematically by evaluating possible approaches:

1. Bundling OpenSSL DLLs in the libtorrent Wheel

  • Include libcrypto-1_1-x64.dll and libssl-1_1-x64.dll in the Windows wheel package.
  • Users can install the wheel without needing to manage DLLs manually.
  • Pros: Simple for users.
  • Cons: Larger wheel size, requires regular updates for security.

2. Requiring a Separate Wheel for OpenSSL

  • Create a new wheel package (libtorrent-openssl or libtorrent-windows-dll) that installs the required DLLs alongside libtorrent.
  • Notably, in Issue #7338, a user mentioned creating a custom wheel package (libtorrent-windows-dll) to address this problem. This package contained the missing DLLs and placed them next to the .pyd file in site-packages/libtorrent. A similar approach could be formalized to ensure seamless installation.
  • Automatically install this dependency when installing libtorrent.
  • Pros: Keeps libtorrent lightweight, DLLs are managed separately.
  • Cons: Adds complexity and requires coordination between the two packages.

3. Static Linking of OpenSSL Libraries

  • Build the libtorrent wheel with statically linked OpenSSL libraries.
  • Pros: No runtime DLL dependency.
  • Cons: Larger binary size, harder to update OpenSSL for security.

4. Dynamic Download of DLLs

  • Modify the libtorrent wheel to download the required DLLs at runtime if missing.
  • Pros: Keeps the wheel lightweight, always fetches the latest DLLs.
  • Cons: Requires internet access and adds runtime complexity.

5. Improved Documentation

  • Update installation instructions to clearly explain how to install and configure OpenSSL manually on Windows.
  • Pros: Simple for maintainers.
  • Cons: Leaves the burden on users.

Workarounds

Until a permanent solution is implemented, users can resolve the DLL import errors with the following workarounds:

Option 1: Place DLLs in System32 (default PATH location)

  • Download the required DLLs (libcrypto-1_1-x64.dll and libssl-1_1-x64.dll) from a trusted source, such as the official OpenSSL binaries.
  • Copy these DLLs to C:\\Windows\\System32, which is included in the PATH by default.

Option 2: Place DLLs next to the .pyd

  • Locate the libtorrent.cpXXX-win_amd64.pyd file in your site-packages/libtorrent directory (e.g., C:\\Python310\\Lib\\site-packages\\libtorrent).
  • Download the required DLLs and place them in the same directory as the .pyd file.

These workarounds should resolve the import errors until a more seamless solution is provided.

Call to Action

We invite feedback from the community and the maintainers, especially @arvidn @AllSeeingEyeTolledEweSew and @baseplate-admin, on which approach to pursue. Let us collaboratively decide the best way to resolve these recurring DLL import errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions