I have installed the current Qt 5.8 inside a users home directory and now try to use it since three days. Cmake always uses the system wide Qt installation and kdevelop does the same. No CodeCompletion on the new stuff and so on...
I tried to install it system wide in /opt/Qt but nothing changed.
So can please anyone tell me what environment variables do I have to change to integrate the current Qt Version in my Development System?
Many Thanks
By the way - it is a kdevelop 5.0 running on a Debian Linux testing
From cmake does not find qt 5.1.1 question:
You need to set the CMAKE_MODULE_PATH to the Qt installation where the *.cmake files are located. This CMake variable is used to select which Qt installation to use for compiling. There is also a`CMAKE_PREFIX_PATH environment variable.
See http://doc.qt.io/qt-5/cmake-manual.html
The code completion: in project settings add to include paths something like:
/.../.../5.8/gcc_64/include/QtGui/
/.../.../5.8/gcc_64/include/QtCore/
/.../.../5.8/gcc_64/include/QtQuick/
...
Edit: The following is only correct for Qt4 and not for Qt5!
The default qt version found by cmake is the one assoziated with the qmake binary in your $PATH. Run which qmake in order to find out which one it is. It will probably be the system-wide one. The fastest way to coerce cmake into finding your custom version is then adding your Qt's bin folder to the $PATH as the first entry and running kdevelop from that command line: PATH=/opt/Qt/5.8/bin:$PATH kdevelop. Code completion should then also work, as AFAIK kdevelop uses the include folders evaluated by cmake for code completion.
You might want to consider switching to QtCreator, which fixes this problem by listing all Qt versions as "Kits" which you can select in the project settings.
Related
I am trying to install kde-connect following this.
Although my kubuntu version is 14.04, I wanted to compile them so that I can have the latest version. But when I followed the instructions to compile, i get the following error.
-- Found Qt-Version 5.2.1 (using /usr/bin/qmake)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
QT_QT_INCLUDE_DIR
used as include directory in directory /home/vinaychandra/Downloads/t/CMakeFiles/CMakeTmp
CMake Error: Internal CMake error, TryCompile configure of cmake failed
CMake Error at /usr/share/kde4/apps/cmake/modules/FindKDE4Internal.cmake:1311 (message):
Unable to compile a basic Qt application. Qt has not been found correctly.
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindKDE4.cmake:95 (find_package)
CMakeLists.txt:7 (find_package)
Please point out how to correct this.
I have tried giving -DQT_QT_INCLUDE_DIR=/usr/share/qt4/
then it tells that You must build your code with position independent code if Qt was built with -reduce-relocations.
Your cmake by default uses a different QT version.
So, you must explicitly tell him which version of QT he have to use for this job.
This one
-DQT_QT_INCLUDE_DIR=/usr/share/qt4/
Is wrong because you mustn't give QT position explicitly.
All you need is to use the right qmake.
So, give'em this flag and you'll be happy!
-DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4
Since most of kde applications are not ported to Qt5, you need Qt4.x for building kdeconnect(don't know x, mine is 4.8.6).
Also Qt4 installer is not available (I think !), so you have to build it also from source. Building Qt4 is quite easy, just download the source and run the usual commands.
After building it, it qmake name will be qmake-qt4 in /usr/bin.
So for building kdeconnect, first run its cmake, then a Cmaketextcache.txt file will form.
In that change the path of qmake (i.e somewhere written /usr/bin/qmake to /usr/bin/qmake-qt4) and also the path of qt include dir to (I think /usr/include/qt5 to /usr/include/qt4), and run the cmake again.
If some packages are missing, then you have to install it.
But with the above changes, you will get a make file to install it.
Unfortunately, the cited documentation is lagging behind the current state of kdeconnect. I ran into similar problems but I managed to solve them by installing the following required packages from the Kubuntu repositories:
sshfs
libfakekey-dev
libxtst-dev
libqca2-dev
libqjson-dev
I trust these are all of them. I installed kdeconnect from the latest git commit and it seems to run fine.
This answer comes a bit late, but this is the first Google search result for the question. In systems with qtchooser (Kubuntu, Ubuntu at least), this can be fixed by running first:
export QT_SELECT=qt4
This makes all of the Qt build tools to default to the Qt4 version instead of Qt5. You can check which Qt version is active by running:
qmake --version
Try kde connect install on ubuntu: https://fazlerabbi37.github.io/blogs/install_kde_connect_in_ubuntu_18.04.html
(in 18.04 & 19.04 it works with simple sudo apt install kdeconnect
Install kde connect on android device (google play store is where I installed from)
Invoke kde connect from desktop
Invoke kde connect from android and search device.
Your ubuntu will be found / initiating a search from desktop results in android phone pulled up for pairing
Accept pairing request
Provide access to folders
Try clicking on a video/image file for transfer
I could see the new file transferring in /Downloads folder of desktop
allowing/disallowing desktop to access sms, notifications etc are now a choice
Note: Pl treat this with pinch of salt. This appears very simple, effective for a main reason it worked for me in no time.
I followed these instructions in the configuration of OpenCV SDK for using it in Qt Creator IDE, but I couldn't conclude point 6.5, due to configuration errors in Cmake-GUI. I setup the configuration in CMake of the compilers gcc and g++ contained in Qt folder for MinGW32, and all looks Ok. But when Cmake-GUI starts the process of build configuration it ends up saying
"Error in configuration process, project files may be invalid".
It can't find the following:
QT_QMAKE_EXECUTABLE;
Qt5Concurrent_DIR;
QT5Core_DIR;
QT5Gui_DIR;
QT5Test_DIR;
QT5Widgets_DIR.
After this issue I tried to go on with following points of configuration tutorial, without reaching the final instruction of mingw32-make install. I'm using the following versions of softwares: Qt 5.3.0, OpenCV 2.4.9, CMake 2.8.12.2. My OS is Windows 7.
How can I recover the missing Qt files in CMake configuration?
Is there an alternative way for configuring OpenCV with Qt (like using precompiled build of OpenCV libraries)?
You just need to indicate CMake the correct paths to each one. Click oh the path to browse and set each one individually:
QT_QMAKE_EXECUTABLE;
For this one, you need to search inside the Qt installation folder for the /bin directory. On it, you' ll find the qmake.exe. In my case it was C:/Qt/5.3/winrt_x64/bin/qmake.exe
All the following ones are in the Qt's /lib/cmake directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake :
Qt5Concurrent_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Concurrent
QT5Core_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Core
QT5Gui_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Gui
QT5Test_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Test
QT5Widgets_DIR.
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Widgets
Then click generate. It' ll show a new error and ask you for the QT5OpenGL_DIR. Just as before, show CMake the correct directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake/Qt5OpenGL. Finally, click Configure again, and then Generate, and now you're done creating the build files.
You have to specify the location of Qt manually by passing it as an argument for QT5Core_DIR. Qt5_DIR or CMAKE_PREFIX_PATH does also the trick.
Example
Given your Qt 5 is installed at /opt/selfcompiled/Qt5. When calling cmake, add the flag from above:
cmake -DQt5_DIR=/opt/selfcompiled/Qt5 <pathToSourceDir>
Once the Qt 5 directory is set and found by CMake, all the other variables related to Qt 5 should be found from there, too.
I'm searching for a way to force a specific version of QT in a .pro file. To be more specific, I'd like to force qmake to use only QT 5.x version with my project instead of QT 4.x and QT 5.x
Is there a way to do so?
PS: I'm not asking for a way to stop/halt the compile process (aka check QT version, and if lower than 5.x just throw qFatal/equivalent). I'm looking for a way to actually choose which version to use while generating the Makefile with qmake
You can throw a error if a user is running qmake with a version you do not want him to use. ex:
lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5")
I really doubt you can do this. qmake is a part of framework and goes together with libraries. When you say Qt of specific verion you mean only libraries, but it is not correct.
To use specific version of Qt, you actially need to run different version of qmake. If you are using QtCreator - you should select it in project's options, if not - type absolute path to file qmake. You can find out, which version of Qt qmake uses, you can type qmake --version.
As Amartel wrote in his answer, you should point to the correct qmake version (check it by typing qmake --version in the console)
It might be that your project has been generated using the wrong qmake executable and some files are not removed even if you issue a nmake clean or make clean.
Check that there are no Makefile in the source tree after the clean (these files will typically contain the path to the qt version to use, and if not regenerated correctly will point to the wrong Qt version).
I have compiled qt in to /home/user/Software/qt-4.7.4 folder. Then Iset the path in .profile. I did the static built before to /home/user/Software/qt-4.7.4-static-build. For some reason even after updating the PATH env variable it is not changed to the new path and keep giving me the old qmake version.
I tried source command but it does help, also when I try qmake -version it shows me the old path. if I try qmake in a qt project obviously it gives me
QMAKESPEC has not been set, so configuration cannot be deduced.
Error processing project file: /home/user/testUI.pro
can someone help me to get qt running. I am using ubuntu linux 10.04 and
I think you have to update both the QT and QTMAKESPEC environment variables.
Alight After some head banging and consulting a few people I figured the solution my self. What I forget to mention was that I changed the name of the qt installation folder which is a BIG NO NO. Apparently qmake stores its path statically rather than using the path variable.
I am new to qmake and I am trying to build an existing application. Qt was originally installed in /usr/local/lib/Qt-4.3.5 and 'qmake -query QT_INSTALL_PREFIX' returns that path.
I have moved the Qt library to another location and the generated Makefiles are peppered with the /usr/local original path.
How can I force qmake to use the new location I selected without recompiling Qt?
I was looking into this and found a way that works (in qt 4.7.2) by customizing qt with a qt.conf file.
In my case, I added a qt4-4.7.2/bin/qt.conf (It must be in the same place as the qmake executable)
With the following contents:
[Paths]
Prefix = c:/my_path/to/qt4-4.7.2
and the qmake -query started returning the proper paths!
See: http://doc.qt.io/qt-4.8/qt-conf.html for more details
[Update:] Since at least Qt 5.3.1 (tested with static versions of 5.3.1 and 5.5 on Windows 8) you can simply do
[Paths]
Prefix = ..
and deploy the Qt installation anywhere.
This is a 'builtin' compiled into qmake from qconfig.cpp. The best way is to reconfigure Qt with another -prefix and rebuild unfortunately. For most other variables, you can use a .qmake.cache file. See
http://doc.qt.digia.com/qt/qmake-environment-reference.html
for more info
As pointed out by Henrik Hartz, QT_INSTALL_PREFIX is built-in and can't be changed. However, if you just want to work around having to rebuild Qt temporarily, then you can try the following:
Query qmake for it's install prefix, recreate the reported directory structure, and use a symlink or hardlink to where the relocated Qt version is. E.g. on Linux
Get the path reported by /new/Qt/location/bin/qmake -query QT_INSTALL_PREFIX. Say this reports /Parent/Dirs/Prefix.
Create any parent directories of the path, e.g. mkdir -p /Parent/Dirs/
Symlink to new location, e.g. ln -s /new/Qt/location /Parent/Dirs/Prefix
The above can be also useful if you have a bunch of developers who need to work with the same prebuilt version of Qt, where this Qt version isn't necessarily copied to the same path on all the developers' computers, and where you only need to bundle the Qt shared libs with you application for end users (i.e. you won't be shipping headers or build tools).