Running Qt C++ Programs on the XGrid
Contents |
The Problem
- We have an executable generated by compiling a C++ program using the Qt 3.6 libraries.
- Want to run the Qt executable on the XGrid.
- Qt 3.6 is not installed on the XGrid clients
- Qt was installed assuming its libraries would be loaded dynamically.
- We don't want to reinstall or reconfigure Qt.
The solution
- Use otool to find all the libraries that are not standard (we assume they are all in /opt/local/lib) and assume that they will not be on the client.
- Copy all these libraries next to the executable, and modify the executable with install_name_tool such that the path of the libraries as it wants to refer to them is not absolute, but becomes whatever the executable path is.
- For example, if the executable contains a reference to /opt/local/lib/libqt-mt.3.dylib, it should be changed to @executable_path/libqt-mt.3.dylib.
- This process is repeated for all the libraries brought in, so that if they too rely on non-system libraries, they will be modified to have a new path to them, and these libraries will be brought in in turn.
- To do this efficiently, we use a Python utility called makeStaticPackage.py.
- makeStaticPackage.py must be started in an empty directory and copies into it the original executable, as well as all the non-system libraries, one after the other. It then generates a text file that can be used by another Python script for creating an XGrid batch file.