How do I move ~/Qt to /usr/local/share/Qt?
-
When I started the qt-unified-linux-x64-2.0.3-1-online.run installer, it asked where I wanted to put my "Qt" directory.
I chose my home directory, then thought better of it, but wasn't able to change that setting by hitting the Back button.
I killed the installer and then restarted it, and found that I still couldn't change it.How do I move ~/Qt to /usr/local/share/Qt and have Qt be able to find it?
-
Hi, because the installer modifies some Qt files depending on where you wanted it installed, I don't think it's easy to move Qt to another location. You could try starting MaintenanceTool (if that app is not yet installed, let the installer finish the installation in ~/Qt) and Remove all components, then download the installer again and then select /usr/local/share/Qt.
-
@SKelem said in How do I move ~/Qt to /usr/local/share/Qt?:
How do I move ~/Qt to /usr/local/share/Qt and have Qt be able to find it?
Or symlink the folder, if you're feeling lazy and/or you don't want to deal with the implications of actually moving the binaries for now.
PS.
I really find it a bad idea to put Qt in/usr/local/share
. Linux distributions can get really touchy about alien files put into system locations, and of course it's not needed, nor is it the place for such files. Local installations are much cleaner, don't conflict with the distributions' package managers and naturally work just as well. -
@SKelem I think it's a bad idea to move the files to /usr/local/share.Instead you can change the path by trying this command
PATH=/path/to/installed/qt:$PATH
and you can use the latest versions of qmake(depends on your instlled version of Qt) etc...
-
@SKelem ... Yes, it is generally bad to install into /usr/local/share as share is more like AppData or ProgramData on Windows. You can safely install into the /usr/local folder and 99% of distros will not care.
When doing so, you will need to make sure the ldconfig is setup properly and the global profile is modified to allow all to use Qt! Note: the paths in the example are for my system which is Fedora based. You will need to look at your distro in case the names are different. Also, you may have to talk to your admin if you do not have authority to do this on your own.
To make ldconfig work properly, add a file to /etc/ld.so.conf.d for Qt. Here is an example for CentOS/Fedora, Qt5.7, installed in /usr/local:
cd /etc/ld.so.conf.d
sudo vim qt-5.7-x86_64.conf
<add the following lines>
/usr/local/Qt5.7.0/5.7/gcc_64/lib
/usr/local/Qt5.7.0/Tools/QtCreator/lib/qtcreator
<save and exit>
sudo ldconfigThe above will tell Linux to look for the .so files in the two paths specified in the config file.
Next you will want to permanently update any profile to look for qt items in case you run on the command line. The MaintenanceTool will typically only modify the user interface to allow you to access Qt tools via
icons. Here is an example for CentOS/Fedora, Qt5.7, installed in /usr/local:
cd /etc/profile.d
sudo vim qt-5.7.sh
<add the following lines>
if [ -d "/usr/local/Qt5.7.0" ]; then
export PATH=$PATH:"/usr/local/Qt5.7.0/5.7/gcc_64/bin":"/usr/local/Qt5.7.0/Tools/QtCreator/bin"
fi
<save and exit>The above script will be run every time a new console or the system is rebooted.
By following those basic configuration steps for your distro, updates will NOT harm what you have done unless you totally destroy the disk. These will be permanent for everyone using the system. Just remember that when you get a new version of Qt and install it, those paths will change so the scripts must be updated.
I hope this helps! Its always fun to not have to worry about the nit-noids and do the great stuff like play with Qt!
-
You can just move it with
sudo mv Qt /usr/local/share/Qt-x.y.z
. Then instead of adding the libraries to ld.so.conf I prefer to control my "development" version of Qt via my bashrc. Almost all linux systems will have Qt installed system wide which is not necessarily the same one I use for development.So I just make sure I have this in my bashrc:
PATH="/usr/local/share/Qt-x.y.z/<your compiler>/bin:$PATH" QTDIR="/usr/local/share/Qt-x.y.z/<your compiler>" export PATH QTDIR
Now restart your shell, and try
qmake --version
. It should show your /usr/local/* path.You may need to set a qt.conf in the bin/ directory of your Qt install to point your Qt binaries and libs at your new directory.
It would look like this (if necessary, it may not be for your install):
[Paths] Prefix = /usr/local/share/Qt-x.y.z/<your compiler>/x.y.z/bin
Like others have said though, /usr/local/share is not the right location. I use
/opt/Qt-x.y.z
or/usr/local/Qt-x.y.z
and I like to symlink/usr/local/Qt
or/opt/Qt
to the versioned one. This makes it easy to set my path to/opt/Qt/<compiler>/bin
so when I install new Qt's I just update the symlink and not have to deal with my bashrc.