Home > database >  We have a external .lib that links to Qt5Core.dll but our environment contains Qt5Core_conda.dll
We have a external .lib that links to Qt5Core.dll but our environment contains Qt5Core_conda.dll

Time:08-04

We have an external library (Foobar.lib), provided by a customer, that is linked against Qt5Core.dll. We have to use that library in our own code.

In our environment, we use conda and conda-forge provided Qt libraries, and the conda-forge maintainers decided to append the suffix _conda to all the .lib and .dll files (not sure why), so we end up with Qt5Core_conda.dll in our PATH.

This is a problem because our runtime either does not find Qt5Core.dll, or it loads up Qt5Core.dll and Qt5Core_conda.dll at the same time, which does not work because globals from one library are not seen by the other (notably the QApplication global).

One thing that ocurred to us is to open Foobar.lib and manually change the references from Qt5Core.dll to Qt5Core_conda.dll, however given that the name is larger we would need to add new bytes to the file, which would mess up the addresses inside it (we suspect that if we wanted to reduce the name it would be possible).

We are looking for a way to update/rewrite Foobar.lib to point to Qt5Core_conda.dll instead of Qt5Core.dll, any suggestions?

Our environment is Windows.

CodePudding user response:

While patching the original library could be possible (but only if done with extreme caution and with the correct tools), I wouldn't suggest that.

For a generic case, a logical and simple solution would be to simply copy the library using the required name, but this wouldn't probably work properly for Qt for various reasons.

A viable solution is instead to create a hard link, which is a dynamic and transparent reference that makes it look like it's the actual file, as opposed to the common Windows lnk interface. When a hard link is created, the access to the link works exactly like accessing the original file: the only difference is the path and file name, but they both refer to the same data object in the file system.

You will need to use the mklink command in the command prompt, with the /h flag (for the hard link) and the target path followed by the source path:

mklink /h "path/to/Qt5Core.dll" "path/to/Qt5Core_conda.dll"
  • Related