Flags like QT_QTGUI_LIBRARY and QT_USE_FILE are returning the paths to an older version of Qt, even though I have FIND_PACKAGE(Qt4 4.8.2 REQUIRED) at the top.
How do I go about fixing this?
Delete CMakeCache.txt in your build directory and generate again. Sometimes it's necessary to update CMakeCache.txt especially if you upgrade some sided library used by you in your project.
Related
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.
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 had a kit set up in Qt Creator 3.0.1 that pointed to my cross toolchain. This worked until I ran into a bug in the compiler and now have to upgrade to a newer version.
I've obtained a newer toolchain. I went into Creator, edited my kit, and updated the path to the compiler and gdb binary to point to the new toolchain.
However, when I build my project, it's still calling the old toolchain's compiler.
I've even completely deleted my kit, compiler, and debugger and recreated their configuration, but no joy.
I double-checked the mkspec that is being used, and there is nothing in there with hardcoded paths to the compiler, just things like QMAKE_CXX = $${CROSS_COMPILE}g++. I don't have the CROSS_COMPILE variable set. I did try setting it (in Creator's build environment editor) but no joy there either.
How do I get Creator to use my new toolchain?
EDIT - NEW INFO
I tried running the same qmake command line Creator does when it builds (according to its build output). First, the call to qmake I'm making is returning to the command line without creating a makefile. Here is the command I'm running:
/qt5/bin/qmake /s/src/tfs/porject_dirs/Myproject.pro -r -spec devices/linux-am335x-g++ CONFIG+=declarative_debug CONFIG+=qml_debug
So, I added a -d to get some qmake debug output. I found some fishy lines that pointed to some files that are in my mkspecs directory.
What are these files that were installed when I built Qt?
qconfig.pri
qdevice.pri
qfeatures.pri
qmodules.pri
Three of the four (not qfeatures.pri) include in them hard coded paths to the compiler I used to build Qt. I suspect that these are my problem.
Why does Qt Creator allow a compiler to be specified if these files might be overriding it? Is it safe to edit these files? Do I have to rebuild Qt simply to change the compiler used to build my application?
There is, an open bug in Qt that leaves hardcoded paths in the .pri files mentioned in my question.
Update
The bug has been resolved.
I just updated my Qt to 4.8.3, because the program built from older version is not compatible to the new framework.
So I have to upgrade.
This process was frustrating and time consuming. So many problems came out.
I download Qt from this url:
http://qt-project.org/downloads
At beginning, I installed the MinGW one (I'm not a fan of MSVC).
I tried the newest ( I think it's 4.6) version of MinGW and order version (4.4).
However, after I installed MinGW and tried to install Qt 4.8.3, during the process, the following message shows up:
There is a problem with your MinGW installation:
The installer could not find a valid C:\MinGW\include\w32api.h (Only versions with W32API 3.13 are supported)
Do you still want to continue? (Your installation may not work)
The 4.6 version does have this w32api.h file, I don't know what's going on. And I have trouble finding MinGW 4.4 with this head file.
I decide to ignore this warning and continue to install Qt and Qt creator. After that,
I opened my current project, configure it (why the configuration become so complex...), I tried to build it.
Then the following message shows up because some external lib I used requires Exception Handling:
exception handling disabled, use -fexceptions to enable
And I don't know how to enable the it.
I tried to add -fexceptions flag in QMAKE_CXXFLAGS but it doesn't work.
By the way, I tried the VC version of Qt too, but I used the MinGW before and the VC compiler is quite different, if I use VC version, it will take a lot of time to make it compilable by VC compiler.
Does anyone know how to install Qt 4.8.3 on Windows? my project works fine before, now I just want to compile it successfully.......
These are not the only problem.
I updated the Qt on Mac machine too, it is easier to have the compiler work since it's unix base.
However, I used QtWebkit lib in my project and obviously, they changed this lib and it's not compatible to order version.
I can compile my project on Mac, however, every time I run it, following massage shows up and the program stopped.
dyld: Symbol not found: _OBJC_CLASS_$_CALayerHost Referenced from:
/Library/Frameworks/QtWebKit.framework/Versions/4/QtWebKit Expected
in:
/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
The program has unexpectedly finished.
Does any one know how to solve this QtWebKit problem? I'll really appreciate.
I remembered that when Qt is under nokia, it's so easy to install and use, the Qt SDK is perfect.
I really hate the change made after it was bought by digia.........
I found solutions of my first two problems:
for the first problem, as I described, download the MinGW provided by Nokia Qt
ftp.qt.nokia.com/misc/MinGW-gcc440_1.zip [ftp.qt.nokia.com]
Tried several versions of MinGW 4.4, I think this is the only one works.
About the second problem, add following configure in the project file:
CONFIG += exceptions
Now the QWebKit problem is only one unsolved.
Is it all relevant that your include directory for MinGW has two "i's" in it or was that a typographic error when posted on SO? See:
The installer could not find a valid C:\MinGW\iinclude\w32api.h
I am attempting to compile a software that I have built using Qt, ITK, VTK, using mingw32 on Windows 7. I have successfully done this on many computers, but I am having trouble on my laptop.
I made a mistake when I first installed Qt on this machine, in that I installed the "msvc2010" or visual studio verision of Qt. I had VS installed, and this is what it defaulted to, and I did not change it. Realizing my mistake, I uninstalled all traces of this Qt, and installed the Mingw32 version. The exact version I downloaded was: Qt libraries 4.8.3 for Windows (minGW 4.4, 317 MB)
I installed mingw32, installed qt, all nice and dandy, and now I am compiling my software. It builds beautifully, but during the linking stage I get the following nasty error:
mingw32-make[2]: *** No rule to make target 'C:/QtSDK/Desktop/Qt/4.8.1/msvc2010/
lib/QtOpenGL4.dll', needed by 'x.exe'. Stop.
CMakeFiles\Makefile2:62: recipe for target 'CMakeFiles/x.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/x.dir/all] Error 2
Makefile:74: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Where x is the name of my project.
Note the make target: C:/QtSDK/Desktop/Qt/4.8.1/msvc2010/lib/QtOpenGL4.dll. This is NOT the correct place to look for the DLLs. It is looking at the lib location of my first installation of Qt. The QtSDK folder does not even exist anymore, the new version is under a different folder.
This is sadly also reflected in the link.txt under CMakeFiles that is generated in the build folder by cmake. One of the entries is:
C:\QtSDK\Desktop\Qt\4.8.1\msvc2010\lib\QtGui4.dll
along with many other DLLs.
Clearly, the problem is that Cmake is generating targets for the previous version of Qt.
How can I erase whatever ridiculous cache this is originating from, so that it does not do this? I have reinstalled Cmake, I have reinstalled Qt, I have done everything I can think of. I have verified that the Cmake variable are all pointing to the correct Qt folder (the other one does not exist, so no way we could get to the linking stage if they were incorrect).
Thank you so much.
EDIT:
I get this very pertinent warning, that has the wretched file path in it:
CMake Warning (dev) at CMakeLists.txt:22 (ADD_EXECUTABLE):
Policy CMP0003 should be set before this line. Add code such as
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
as early as possible but after the most recent call to
cmake_minimum_required or cmake_policy(VERSION). This warning appears
because target "x" links to some libraries for which the linker must
search:
comctl32, vfw32, ws2_32, wsock32, -lgdi32, opengl32
and other libraries with known full path:
C:/Qt/4.8.3/lib/libQtGui4.a
C:/ITK/lib/libitksys-4.1.dll.a
C:/VTK/bin/libQVTK.a
C:/QtSDK/Desktop/Qt/4.8.1/msvc2010/lib/QtOpenGL4.dll
CMake is adding directories in the second list to the linker search path in
case they are needed to find libraries from the first list (for backwards
compatibility with CMake 2.4). Set policy CMP0003 to OLD or NEW to enable
or disable this behavior explicitly. Run "cmake --help-policy CMP0003" for
more information.
This warning is for project developers. Use -Wno-dev to suppress it.
I added the "NEW" policy, and the warning went away, but I still have the same problem.
The problem turned out to be that I had installed VTK while I had the old Qt (configured for VS2010 installed). When I included VTK's libraries, it also included DLLs from Qt--but it was still pointing to the old Qt.
I reinstalled VTK, and we got past this step.
Try to regenerate cmake files, :
mingw32-make clean
cmake .
Short version: You need to delete your CMakeCache.txt file in your build directory.
Long version: Whenever CMake searches for external libraries/programes etc (eg. by FIND_LIBRARY which is called when searching for Qt, for example), it saves the result in the cache. On subsequent runs, it simply uses the cached value (if any) instead of searching for the libraries again. Therefore, you need to remove these cache entries so that CMake really searches for the libraries again. Simply delete the CMakeCache.txt and start over. If both versions are installed in parallel, make sure that QTDIR environment variable is set correctly and the path includes <QTDIR>/bin, as CMake relies on qmake to find the relevant libraries.
Note: If you don't want to delete the whole cache, deleting the Qt relevant variables should work, too.
cmake -U *QT_* .
should do the trick.
However, deleting the whole cache is the cleanest solution.