How does the Qt Win32 binary installer Qt relocation
If I built Qt from sources, then it is not possible to relocate Qt because the build directory is hardcoded into the Qt libraries. So distributing my Qt version to other co workers in our company is not easy (the qt.conf way does not work with Qt Creator). So it would be really interesting to know how the Qt Win32 binary installer does the relocation trick? Any idea?
Are you talking about *nixes? There is flag -prefix for configure script.
that would still be interesting, if someone from nokia could post a reply here
Since there after all seems to be interest about this, I’ll post few things.
On nixes, there is quite many ways to do this. Most favorable way is to have library paths in system configure files (ld.conf.so and so on), which specifies the paths where missing libraries will be looked from. That is, they are first tried to load from current directory, IIRC.
Then one can specify LD_LIBRARY_PATH to specify list of paths where the libs should be loaded from. This overrides the paths specified in configs.
Then one can use runpaths/rpaths to specify fixed location where is this library’s dependecy files. By its nature, it should be clear that this is not good way. It also overrides all stuff specified with above methods.
On Windows, all of this is controlled using variable named PATH. I haven’t really got why, but that’s how it’s done there.
The PATH environment variable is the way to go, but it's pretty simple to patch the core binary in-place for other paths. If you look at "src\corelib\global\qconfig.cpp", you'll see that all library/plugin/doc/etc locations are null-terminated into 524-length arrays; this was obviously done with patching in mind. I imagine the installer patches QtCore4.dll at those array locations to include the install location. Since each array begins with the 12-character string "qt_XXXXpath=", you can patch it with a directory length up to 511 characters before overflowing :). Just make sure to double-backslash the path separator.