Qt on Linux - version conflict? - c++

Trying to move a Qt 4.6.3 project from Windows to Debian Linux (Etch). I've installed Qt by downloading the latest version, then running configure, then make install as root. Yet when I run qmake_qt4 on my project's pri file, here's what I get:
uic: File generated with too old version of Qt Designer
Running uic -v returns 4.2.1. How come? Wasn't make install supposed to put the latest Qt on the system?

By default, Qt installs to /usr/local/Trolltech/Qt-4.6.3 and doesn't add it's bin folder to your PATH variable. Also, it's just named qmake.
Either call /usr/local/Trolltech/Qt-4.6.3/bin/qmake using the complete path or add the /usr/local/Trolltech/Qt-4.6.3/bin/ path to your PATH variable and ensure that it is listed there before any other path that may have a qmake. Best thing to do is to uninstall the the debian qt version if you don't need it elsewhere.

Related

how to specify search directory for source code build

I am trying to install Jom (http://wiki.qt.io/Jom) for C++. When I type in qmake -r in cmd, I get the error Project MESSAGE: Cannot build jom with Qt version 4.8.7. Project ERROR: Use at least Qt 5.2.0.. This is because I have PyQt version 4.8.7 and Qt version 5.8.0 both installed. When building Jom, Jom searches for in the wrong Qt folder. How can I fix this?
If you have multiple version of Qt installed, you also have multiple version of qmake. You can check which qmake you are running by using where qmake on Windows, it will output a list of qmake executable available in your path, the first one in the list will be the one executed when running qmake.
For instance:
C:\>where qmake
C:\Qt\5.8\msvc2015\bin\qmake.exe
C:\Qt\5.6\msvc2015\bin\qmake.exe
If the first one, is not the one you want, you can run it by using its complete path:
C:\>C:\Qt\5.6\msvc2015\bin\qmake.exe -version
QMake version 3.0
Using Qt version 5.6.2 in C:/Qt/5.6/msvc2015/lib
If the qmake and Qt version you want is not in your PATH, you can use the scripts provided by Qt to setup a valid environment. These are available in the Start menu as Qt 5.8 64-bit for Desktop (MSVC 2015) (change according to your installation), or you can use them directly by executing qtenv2.bat (e.g C:\Qt\5.8\msvc2015\bin\qtenv2.bat).
If you are using MinGW you are all set, but if you are using MSVC you need also to run vcvarsall.bat, which can be found in your Visual installation folder.

Is there a way to run qmake with QT 5.7 and above?

I have a project I made with Qt 5.7 in QtCreator, but now I would like to be able to build the project with qmake in the terminal rather than through QtCreator. However, I can't get qmake to run with Qt 5.7.
Following the instructions in this webpage, I can switch qmake to qt5 but qmake -v still says I'm running QT 5.2.1. How can I switch this to Qt 5.7?
Edit: Adrien's second comment worked. I was unable to get qmake to switch to Qt 5.7, but I can simply directly call the qmake that came installed with Qt 5.7 like this:
/home/<user>/Qt5.7/Qt5.7.0/gcc<something>/bin/qmake
Short answer: yes of course :)
Each Qt build builds its own qmake binary. So if you already built/installed Qt 5.7, it means you are simply pointing to your previous Qt version's qmake. You can access any Qt version qmake executable from your Qt install folder, i.e. for Linux:
/home/<user_name>/Qt/Qt<version>/<compiler>/bin/qmake
Note that the path to Qtfolder, and its name may vary depending on the settings you used for the first installation.
If you want to use a global setting instead, and if qtchooser -list-versions lists the Qt version you want to use, then make sure to set export QT_SELECT=<Qt version> (without spaces) in the same terminal as the one you use qmake from afterward. Environment variables are not kept when you close your terminal, or shared between different terminals.
export QT_SELECT=qt5
qmake

Ubuntu 14.04 - Qt version choosing

I mistakenly updated my qt version from 4.8.5 to 4.8.6. This happened as a result of python anaconda installation.
However I am working on a project that needs qt 4.8.5.
Running qmake -v shows:
$ qmake -v
QMake version 2.01a
Using Qt version 4.8.6 in home/<username>/anaconda/lib
How do I switch to my previous qt version (installed in the default directory, i.e. /usr/... )?
qtchooser lists the following options:
$ qtchooser -list-versions
4
5
default
qt4-i386-linux-gnu
qt4-x86_64-linux-gnu
qt4
qt5-x86_64-linux-gnu
qt5
But trying export QT_SELECT with every option didn't change the message:
Using Qt version 4.8.6 in home/<username>/anaconda/lib
I will greatly appreciate your help.
You can easily use several versions of Qt. All you need to do is - call qmake, that comes with the needed version. For example:
/usr/local/Trolltech/Qt-4.8.5/bin/qmake -v
When using QtCreator, you can add Qt version in Tools/Options.../Build & Run and switch between Qt versions in project's settings (some versions on QtCreator will require creating a Kit also, which is not very hard).
The only problem I faced is - using cmake (hate this piece of garbage). In this case you'll need to change the order in which qmake of different versions are called. First of all, find out where your default qmake is located (which qmake), then - whether it is a symlink or not (it is strange, that Qt, installed in your home directory is called without using full path). If it is a link, then change it from one Qt's version to another. If not - examine echo $PATH. What you can do: you can create a symlink for Qt4.8.5's qmake to a directory, which is previous to one, in which Qt4.8.6's qmake is. Or you can add path to it in your $PATH in the first position (sudo nano /etc/environment. Important - in some OS /etc/environment will be empty. In this case you need to write whole $PATH there, like echo PATH=\"/usr/local/Trolltech/Qt-4.8.5/bin:$PATH\" > /etc/environment).

svn - wrong version for Qt Creator on OS x

In my code I need to display the svn version of my project...
The project was created in Windows and uses svn version 1.8.10
On OS X 910.9) the installed version for svn was 1.7.9 so I had to upgrade it.
I got 1.8.10, and checking from the terminal, it shows that.
I added the installed directory for svn to the path. The "set" command now shows
PATH=/opt/subversion/bin:/usr/bin:....
But.... From Qt Creator, I am still unable to use svn:
svn: E155021: This client is too old to work with he working copy at '/path_to_project_folder' (format 31).
You need to get a newer Subversion client. For more details, see http://subversion.apache.org/faq.html#working-copy-format-change
The command '/usr/bin/svn' terminated with exit code 1.
So... it seems that Qt Creator (and the command I call from the project file) uses the old path for svn...
The work-around for now is to hard-code the full path to svn in the pro file (the command that gets the version)
But... How can I get Qt to work with the correct svn version without having to hard-code the path in program ?
I found the Environment section in Qt Creator - which uses its own PATH... doesn't seem to get updated with updates on system PATH but I was able to add to it manually

Stepping into Qt sources in Qt Creator (in Ubuntu Linux)

I'm using Qt Creator in Ubuntu. It's installed from the repositories but as it is now, there is no way to step into the Qt sources when debugging.
How can I enable that?
Since Qt Creator uses gdb, you need to configure gdb. First thing to do is to install Qt debugging symbols:
apt-get install libqt4-dbg
Or, for Qt5:
apt-get install qtbase5-dbg # For the qtbase package
This will install the debugging symbols for Qt libraries. Older releases of Ubuntu had a silly bug that required additional trick to correct those symbol files, but in the current release it works fine.
This will make gdb step inside Qt methods, but it's no fun without sources. So we need sources which can be installed like this, assuming that the source repository is enabled in the APT:
apt-get source qt4-x11
ln -s qt4-x11-4.7.0 qt # a convenience symlink
Or, for Qt5:
apt-get source qtbase-opensource-src
# Make a link as above, if you wish
This will download the sources, unpack them into the current directory and patch them accordingly, no root privileges needed unless the current dir isn't writeable by the current user.
And the last thing is to inform gdb of the sources location, which is done by putting this in the ~/.gdbinit file:
dir ~/vita/qt/src/corelib
dir ~/vita/qt/src/gui
dir ~/vita/qt/src/network
dir ~/vita/qt/src/sql
Add modules and correct paths as needed. The convenience symlink is very useful here, so we don't have to edit this file each time we upgrade to a new Qt version. We only need to download the new sources, patch them and change the symlink.
Note that even we have installed the debugging symbols, we still use the release build of Qt libraries. This means that the code is highly optimized and will sometimes behave very strange when stepping inside Qt binaries. If it is a problem, then it is necessary to build Qt in debug mode, install it separately (say, in /usr/local/qt4-debug) and tell Qt Creator to use that particular installation.
The only way i made it work on Ubuntu is building Qt from sources with configure -debug.
Everything started to work like a charm afterwards.
Qt binary packages for Linux don't contain debug symbols and therefore the debugger doesn't know files or line numbers where to jump to. You need to build Qt yourself with -debug configure option if you want to be able to debug Qt code.
Instructions from Sergey Tachenov instructions would only work if you build your application against the Qt version that you can find from Ubuntu repositories.