Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic linking problems with installed package including examples on Windows #225

Open
scheibel opened this issue Mar 7, 2017 · 3 comments

Comments

@scheibel
Copy link
Member

scheibel commented Mar 7, 2017

When installing glbinding, it ships with an own version of Qt.
If a user installs an own version of Qt (probably a newer one) and links its dependencies against glbinding, adjusts the %PATH% such that glbinding is found at runtime, it may happen that Windows chooses the shipped Qt of glbinding instead of the Qt the user wants to use for his/her application.

I think this may be fixed by moving the examples and Qt and GLFW libraries to an example subdirectory for the deployment.

@scheibel scheibel added the bug label Mar 7, 2017
@kateyy
Copy link

kateyy commented Mar 7, 2017

I noticed a related issue with Qt (platform) plugins in my applications: Executables linked to Qt contain the absolute path to the Qt installation that was used at build time (see https://doc.qt.io/qt-5/qcoreapplication.html#libraryPaths). When initializing a Q(Core)Application it will by default load platform plugins etc. from the original Qt installation path, if it exists on the target machine. Otherwise it will search in the application path (but not PATH or similar or the working directory). Thus the mechanism for loading Qt Libraries is completely different from loading Qt Plugins. This happens on Windows and Linux (and probably also on Mac).

So problem now is that different (minor) versions of Qt Libraries and Qt Plugins might be used at runtime, which might lead to application crashes if these versions are not compatible (such with 5.2.1/5.2.0 breaking binary compatibility). I have had this issue a few times when deploying my application and fixed by adjusting the Qt Library paths using a qt.conf file and manually setting the library paths.

This problem might not be relevant for glbinding itself, but with gloperate etc. it can cause problems when users are free to use their own Qt installations instead of the ones gloperate etc. were linked to.

@scheibel scheibel added this to the v3.0 milestone Apr 3, 2017
@scheibel
Copy link
Member Author

scheibel commented Apr 3, 2017

@kateyy You suggest to add qt.conf files for every Qt-based executable?

@kateyy
Copy link

kateyy commented Apr 3, 2017

I'd recommend a solution like that. Contrary to what you originally suggested, I use this solution to prevent the Qt application from using Qt libraries/plugins that are already installed on the target system. You can't check at application startup, if an installed Qt version on the target system is actually compatible to your linked Qt version.

PATH is used by windows to locate Qt libraries. But the path to Qt plugins is hardcoded into the QtCore library and is not influenced by PATH. So even if the user has an installed Qt version that is found in the PATH, the application will still use your deployed Qt plugins. Or even worse, it might use Qt plugins from a third location that incidentally matches the Qt location from the build machine.

So, you can use qt.conf to specify Qt plugin locations, which is the recommended solution (https://doc.qt.io/qt-5/windows-deployment.html, https://doc.qt.io/qt-5/linux-deployment.html). Or you use QCoreApplication::setLibraryPaths(), which is a bit hacky but doesn't require the qt.conf file. On Windows, you can also use windeployqt.exe which rewrites the plugin path in the deployed QtCore library (but I think it will also write absolute paths only).

@cgcostume cgcostume removed this from the v3.0 milestone Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants