how to change opencv configrations in cmake to support qt - qt

I'm new to opencv. I installed it on my computer using cmake following the tutorial in their website.
mkdir Desctop/opencv
cd Desctop/opencv
git clone https://github.com/Itseez/opencv.git
cd opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
And to compile with opencv using cmake, I add the CMakeLists.txt file in the cpp file directory then execute
cd <cpp file directory>
cmake .
make
But now I know more about opencv. I know that I can make GUI windows with it; I can make buttons, scroll bars and many other UI controls.
But I can't use the GUI tools unless I integrated cmake with QT.I'm not sure how should it be, but I thing it would be something like
cmake -D WITH_QT=ON ..
Reference
But the problem is that I've already installed opencv and I don't know how can I change it's configurations to use QT.
I tried to install cmake-gui to change the opencv installation configurations but I didn't find anything for opencv in the program.
My questions
Do I need to re-install opencv or it's possible to change the settings or changing the content of CMakeLists.txt file?
How can I change the configurations of the current opencv installation so it support QT?
would I need to change the CMakeLists.txt file after changing opencv's configurations?

Related

Qt Creator running CMake with different configuration

I'm trying to build a CMakeLists project using Qt Creator 4.8.1. The problem is, I need to run CMake inside a different nativesysroot.
I tried to create a bash script that runs CMake inside the other environment and added it to my kit. As follows:
#!/bin/bash
cd ~/Desktop/Workspace/my_proj/build &&\
~/Desktop/Workspace/my_proj/sdk-x86_64/opt/nativesysroot/usr/bin/sysroot\
~/Desktop/Workspace/my_proj/sdk-vmwx86-x86_64/opt/nativesysroot/usr/bin/cmake "$#"
Such that, sysroot is an executable that changes the current nativesysroot.
The problem is this does not work because Qt Creator is trying to run CMake using the following configuration:
Running "/home/***/Desktop/Workspace/my_proj/script.sh -E server --pipe=/tmp/cmake-.ewYqvn/socket --experimental" in /tmp/QtCreator-kruzfX/qtc-cmake-YOZsCIQx.
This of course causes CMake server connection lost. I tried the look around how to disable the CMake running in server mode but I did not find anything in Qt Creator.
My question is, how to disable CMake in server mode? Or, how to instruct Qt Creator to run my script without adding any flags or options?
Thanks.

Statically installing Qt4 such that OpenCV can detect the installed Qt4 libraries

I am currently using Ubuntu 14.04 LTS.
How can I statically build Qt 4.8.5 -
https://download.qt.io/archive/qt/4.8/4.8.5/qt-everywhere-opensource-src-4.8.5.tar.gz
such that when I cmake OpenCV 2.4.13 -
https://github.com/opencv/opencv/archive/2.4.13.zip
it correctly identifies the location of Qt4 ?
When I cmake OpenCV after I have installed Qt4 in /usr/local/qt4-static/, the find_package(Qt4 REQUIRED QtCore QtGui QtTest) function call within opencv-2.4.13/cmake/OpenCVFindLibsGUI.cmake fails because it cannot find qmake. Also, upon running the qmake -query in the terminal, Ubuntu says that qmake is not installed, when it clearly in /usr/local/qt4-static/.
How should I go about this so OpenCV cmake correctly recognizes Qt4 ?
Build Qt
Extract the source-code and run ./configure && make and then sudo make install. It should create all necessary configuration to run qmake in any folder (system-wide).
Additional: create a symlink/export (use only if make install did not work for you)
You need to promote qmake to $PATH or create a symlink, but this is usually done when you run sudo make install after make in the Qt source-folder.
root:/home# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:
Symlink (permanently)
ln -s /path/to/qmake /usr/sbin/qmake
or
export (temporary)
export PATH=$PATH:/folder/of/qmake
Afterwards qmake -v is working whereever you are
root:/tmp qmake -v
QMake version 3.1
Using Qt version 5.10.1 in /usr/local/Qt-5.10.1/lib
If your project still cannot determine the location of Qt, read the pro/pri/cmake file to understand how it looks for the path.

qmake set install directory

I'm trying to build Qwt to a custom location. The obvious thing to try is a PREFIX option, but it had no effect and the make install still failed:
$ qmake qwt.pro PREFIX='/my/path'
$ make
$ make install
mkdir: cannot create directory `/usr/local/qwt-5.2.3': Permission denied
There seem to be numerous other questions and answers to this question, which also have no effect and fail:
How to change qmake PREFIX location: qmake -set prefix '/my/path'
How can the install path be set for a qt project: make; INSTALL_ROOT=/my/path; make install
Any other suggestions?
QMake version 2.01a
Using Qt version 4.5.3 in /opt/Qt4/4.5.2/qtsdk-2009.04/qt/lib
RHEL 5.10
Try to edit the qwtconfig.pri file in the source directory, it has the installation path hardcoded for different platforms, as well as many other options you might want to change.

compiling musescore for uCLinux with QT and cmake

I've try few things but I still have this error when trying to cmake for blackfin:
CMake Error at CMakeLists.txt:116 (message):
Fatal error: QT (version >= 4.5.0) required. Cmake tries to detect QT4 by
searching for 'qmake' in your PATH.If you have QT4 installed, make sure
qmake is found in your PATH. If you compiled QT4 yourself make sure your
new qmake ist found _first_ in your PATH.
I'm trying to compile the source of musescore 0.9.5 to keep it compatible with the existing version of QT in uClinux options
What I did is to compile the uClinux kernel with QT lib so I can have the suitable embedded QT.
then I modified the Makefile of musescore to build with uclinux compilers. I've try different things so I show here the latest trial:
bfin:
mkdir build;
mkdir install; \
cd build;
cmake -DCMAKE_TOOLCHAIN_FILE=bfin.cmake -DCMAKE_VERBOSE_MAKEFILE=TRUE -\
DQT_QMAKE_EXECUTABLE=/home/william/Development_new/Music_Recognition/code/uCLin\
ux/rev2011R1/uclinux-dist/lib/qt-embedded/build-qt-embedded-linux-opensource-sr\
c-4.5.1/bin -libdir=/home/william/Development_new/Music_Recognition/cod\
e/uCLinux/rev2011R1/uclinux-dist/lib/qt-embedded/build-qt-embedded-linux-openso\
urce-src-4.5.1/lib \
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
mscore;
in the CMakeLists.txt I did add:
link_directories(/home/william/Development_new/Music_Recognition/code/uCLinux/r\
ev2011R1/uclinux-dist/lib/qt-embedded/build-qt-embedded-linux-opensource-src-4.\
5.1/bin)
SET(CMAKE_MODULE_PATH /home/william/Development_new/Music_Recognition/code/uCLi\
nux/rev2011R1/uclinux-dist/lib/qt-embedded/build-qt-embedded-linux-opensource-s\
rc-4.5.1/bin)
SET(CMAKE_PREFIX_PATH /home/william/Development_new/Music_Recognition/code/uCLi\
nux/rev2011R1/uclinux-dist/lib/qt-embedded/build-qt-embedded-linux-opensource-s\
rc-4.5.1/bin)
SET(QT_QMAKE_EXECUTABLE /home/william/Development_new/Music_Recognition/code/uC\
Linux/rev2011R1/uclinux-dist/lib/qt-embedded/build-qt-embedded-linux-opensource\
-src-4.5.1/bin)
my bfin.cmake look like that:
# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
#
SET (BFIN "/opt/uClinux/bfin-uclinux")
# specify the cross compiler
SET(CMAKE_C_COMPILER ${BFIN}/bin/bfin-uclinux-gcc)
SET(CMAKE_CXX_COMPILER ${BFIN}/bin/bfin-uclinux-g++)
SET(CMAKE_LINKER ${BFIN}/bin/bfin-uclinux-ld)
#/opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/lib
LINK_DIRECTORIES("${BFIN}/usr/lib")
SET(CMAKE_FIND_ROOT_PATH
/opt/uClinux/bfin-uclinux/bfin-uclinux
/opt/uClinux/bfin-linux-uclibc
/opt/uClinux/bfin-linux-uclibc/bfin-linux-uclibc/runtime)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Thanks in advance for the help,
William
You need to put qmake in your $PATH. If you prefer to use QT_QMAKE_EXECUTABLE it has to point to the actual qmake binary and not the directory.
That being said, MuseScore 0.9.5 is a very very old version of MuseScore, the current version is 1.1 and 1.2 is coming soon. Check http://musescore.org for more information about MuseScore and don't hesitate to contact the developers on #musescore on freenode.net or on the developer mailing list at http://musescore.org/mailing-list

qmake and QT_INSTALL_PREFIX. How can I select a new location for Qt library?

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).

Resources