'Can I change the name of an implicitly linked DLL in an already-built library?

Here's my use case: I am building Python wheels on multiple platforms that contain compiled binary extensions that link to Boost. I need to bundle the relevant Boost DLLs (and a few others) in with the wheels, but I want to avoid DLL hell. On MacOS and Linux I can accomplish this cleanly with 'delocate' and 'auditwheel' respectively. On Windows I'm at something of a loss.

What I'd like to do (but don't know how to do) is change the DLL name inside the binary extension (itself a DLL), so instead of boost_filesystem.dll it would look for boost_filesystem_blargle.dll where 'blargle' is randomly determined and thus unique. Then, I include boost_filesystem.dll under the name boost_filesystem_blargle.dll and there's no chance of conflict.

I'm trying to avoid anything like delay loading that requires changing the source code of the library I'm working with -- this needs to operate as a post-build step. Also, some of the DLLs export classes, which seems to torpedo delay loading entirely.

Is this even possible on Windows?



Solution 1:[1]

See machomachomangler, which can be used to mangle the names of DLLs. Or if you want a tool that can bundle DLLs with Python wheels while mangling their names, you can try delvewheel, which uses machomachomangler internally.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 adang1345