How to install QMultimedia on ubuntu - qt

I have a c++ project in which I want to use QMediaPlayer, but when I include it its give me error saying
fatal error: QMediaPlayer: No such file or directory
5 | #include <QMediaPlayer>
| ^~~~~~~~~~~~~~
I have the Qt package in my home directory('~/Qt') it is 6.1.2 version, I checked its include and wasn't able to find QtMultimedia.
I tried to install QtMultimedia with sudo apt-get install qtmultimedia5-dev after the installation was complete, still I wasn't able to find QMultimedia in ~/Qt/6.1.2/gcc_64/include/
I have tried this module "QtMultimedia" is not installed
Even though this I edited my CMakeLists.txt to find it
find_package(QT NAMES Qt6 Qt5 COMPONENTS
Core
Gui
Multimedia
Widgets
Concurrent
Network
REQUIRED
)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS
Core
Gui
Widgets
Multimedia
Concurrent
Network
REQUIRED
)
when rebuilding it with cmake --build . it gave me the same error ie
fatal error: QMediaPlayer: No such file or directory
5 | #include <QMediaPlayer>
| ^~~~~~~~~~~~~~
compilation terminated.
So instead of including it this time I directly used it but it still gave me error
‘QMediaPlayer’ does not name a type
20 | QMediaPlayer player;
| ^~~~~~~~~~~~
I am on ubuntu 20.04

Related

How to compile Qt 3.3.6 for use in VC2012?

I need to compile Qt 3.3.6 on my Win 7 PC to use it in combination with my MSVC2012 C++ compiler (MSVS 2012 Professional).
The simple reason is that I have a Qt 3.3.6 license and a lot of Qt 3.3.6 source code. So, a Qt upgrade is not an option. "Google" does not help...
Edited:16/11/10 1:40 pm
I already tried to compile it by starting a shell via VS2012 (Tools/VisualStudioCommandPrompt) and changing the cwd to the Qt directory containing the appropriate Makefile:
C:\Qt\3.3.6>bin\configure.exe -redo -spec win32-msvc2012
License file not found in C:/Users/mdew
Enterprise modules will not be available.
QMAKESPEC...................win32-msvc
Maketool....................nmake
[...list of all the installed programs...]
Configuration:
nocrosscompiler
dialogs
iconview
kernel
styles
tools
widgets
workspace
minimal-config
small-config
medium-config
large-config
full-config
release
thread
no-gif
zlib
jpeg
mng
png
bigcodecs
no-tablet
Debug symbols...............no
Thread support..............yes
Accessibility support.......no
Big Textcodecs..............yes
Tablet support..............no
STL support.................yes
Additional exports..........no
Exception support...........yes
RTTI support................yes
OpenGL support..............no
Image formats:
GIF support.............no
MNG support.............qt
JPEG support............qt
PNG support.............qt
Styles:
Windows.................yes
Windows XP..............no
Motif...................yes
Platinum................yes
MotifPlus...............yes
CDE.....................yes
SGI.....................yes
Sql Drivers:
ODBC....................no
MySQL...................no
OCI.....................no
PostgreSQL..............no
TDS.....................no
DB2.....................no
SQLite..................no
Interbase...............no
Sources are in..............C:\Qt\3.3.6
Install prefix..............C:\Qt\3.3.6
Headers installed to........C:\Qt\3.3.6\include
Libraries installed to......C:\Qt\3.3.6\lib
Plugins installed to........C:\Qt\3.3.6\plugins
Binaries installed to.......C:\Qt\3.3.6\bin
Docs installed to...........C:\Qt\3.3.6\doc
Data installed to...........C:\Qt\3.3.6
Translations installed to...C:\Qt\3.3.6\translations
Creating qmake...
Microsoft (R) Program Maintenance Utility Version 11.00.61030.0
Copyright (C) Microsoft Corporation. All rights reserved.
cd qmake
NMAKE : fatal error U1077: 'cd' : return code '0x1'
Stop.
Building qmake failed, return code 2
So, my attempt to compile it via MSVS2012 failed. NMAKE gets in trouble.
What am I doing wrong?
Thank you in advance for any hint!
BR mdew
have tried to compile Qt 3.3.6 from source with MSVC2015 and I've success.
Download Qt 3 source from https://sourceforge.net/projects/qtwin/files/Unofficial%20Qtwin/qt-win-3.3.6-6/
you must have QTDIR environment variable
set QTDIR=<your path to Qt 3 folder>
make sure bin folder is in your PATH
set PATH=%QTDIR%\bin;%PATH%
replace PATH_MAX with MAX_PATH in following files:
src\tools\qdir_win.cpp
src\tools\qdir.cpp
comment or remove
#include <winable.h>
from
src\kernel\qaccessible_win.cpp
run
configure.bat --help
configure.exe and link_includes.exe will be generated in bin folder.
cd bin
configure.exe -no-dsp -v
if you get errors saing error C3688: invalid literal suffix 'QTDLL_POSTFIX'
delete all QTDLL_POSTFIX in this files:
qmake\generators\win32\borland_bmake.cpp
qmake\generators\win32\mingw_make.cpp
qmake\generators\win32\msvc_dsp.cpp
qmake\generators\win32\msvc_nmake.cpp
qmake\generators\win32\msvc_vcproj.cpp
and change
QString dllStem = stem + QTDLL_POSTFIX;
to
QString dllStem = stem;
in
qmake\generators\win32\winmakefile.cpp
rerun
configure.exe -no-dsp -v
it should now compile successfully

Qt library dependecy under Ubuntu

I have a Qt app with OpenMesh dependency. I built the OpenMesh library from source:
cmake ...
make
make install
It installed to the /usr/local/lib/OpenMesh folder:
libOpenMeshCored.a
libOpenMeshCored.so.3.2
libOpenMeshToolsd.so
libOpenMeshCored.so
libOpenMeshToolsd.a
libOpenMeshToolsd.so.3.2
The libs are included into the Qt project.
LIBS += -L/usr/local/lib/OpenMesh/ \
-lOpenMeshCored \
-lOpenMeshToolsd
When I start the application from Qt Creator, it works fine. But if I start the built executable from command line, it gives back the following error:
error while loading shared libraries: libOpenMeshCored.so.3.2: cannot open shared object file: No such file or directory
So why does it know about, where to find the shared objects, when I start it from Qt, and why not, when I start without it?
And how can I fix this problem?

Cmake can't find Qt OpenGL library

I'm trying to compile a project using cmake. The instructions given to me was that Qt 4.8 is needed. Downloaded it from qt-project.org/downloads. Compiled and installed Qt 4.8:
mazdak#lnxamindai> qmake -query
QT_INSTALL_PREFIX:/usr/local/Trolltech/Qt-4.8.5
QT_INSTALL_DATA:/usr/local/Trolltech/Qt-4.8.5
QT_INSTALL_DOCS:/usr/local/Trolltech/Qt-4.8.5/doc
QT_INSTALL_HEADERS:/usr/local/Trolltech/Qt-4.8.5/include
QT_INSTALL_LIBS:/usr/local/Trolltech/Qt-4.8.5/lib
QT_INSTALL_BINS:/usr/local/Trolltech/Qt-4.8.5/bin
QT_INSTALL_PLUGINS:/usr/local/Trolltech/Qt-4.8.5/plugins
QT_INSTALL_IMPORTS:/usr/local/Trolltech/Qt-4.8.5/imports
QT_INSTALL_TRANSLATIONS:/usr/local/Trolltech/Qt-4.8.5/translations
QT_INSTALL_CONFIGURATION:/etc/xdg
QT_INSTALL_EXAMPLES:/usr/local/Trolltech/Qt-4.8.5/examples
QT_INSTALL_DEMOS:/usr/local/Trolltech/Qt-4.8.5/demos
QMAKE_MKSPECS:/usr/local/Trolltech/Qt-4.8.5/mkspecs
QMAKE_VERSION:2.01a
QT_VERSION:4.8.5
However, when compiling the project I received the following error:
root#lnxamindai> cmake .
-- Setting flags for GNU GCC
-- REQUIRED_VARS (missing: QTMOBILITY_INCLUDE_DIR QTMOBILITY_MULTIMEDIAKIT_INCLUDE_DIR QTMOBILITY_MULTIMEDIAKIT_LIBRARY VERSION_VAR QTMOBILITY_VERSION)
Qt QTOPENGL library not found.
-- Buiding ManyEarsLib Library...
-- Buiding RTAudio Library...
-- Found jack: /usr/lib/libjack.so
ALSA lib : -lasound -lpthread
Qt QTOPENGL library not found.
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:
OPENGL_INCLUDE_DIR (ADVANCED)
used as include directory in directory /home/mazdak/dev/ManyEars/manyears/QtGUI
QTMOBILITY_MULTIMEDIAKIT_LIBRARY (ADVANCED)
linked by target "ManyEars" in directory /home/mazdak/dev/ManyEars/manyears/QtGUI
-- Configuring incomplete, errors occurred!
CMakeLists.txt:
(...)
IF (NOT MANYEARS_GUI_DISABLED)
SET(QT_USE_QTNETWORK TRUE)
SET(QT_USE_QTSVG TRUE)
SET(QT_USE_QTXML TRUE)
SET(QT_USE_QTSCRIPT TRUE)
SET(QT_USE_QTOPENGL TRUE)
SET(QT_USE_QTMULTIMEDIA TRUE)
find_package(QtMobility COMPONENTS MultimediaKit)
find_package(Qt4 4.8.0 QUIET)
if (QTMOBILITY_FOUND)
MESSAGE("QT_MOBILITY_INCLUDE_DIR : ${QTMOBILITY_INCLUDE_DIRS} QT_MOBILITY_LIB: ${QTMOBILITY_LIBRARIES}")
ENDIF (QTMOBILITY_FOUND)
if(QT4_FOUND AND (QT_QTMULTIMEDIA_FOUND OR QTMOBILITY_FOUND))
include(${QT_USE_FILE})
else(QT4_FOUND AND (QT_QTMULTIMEDIA_FOUND OR QTMOBILITY_FOUND))
MESSAGE("WARNING : ManyEars GUI will not be compiled because Qt4 not found or obsolete. You need Qt 4.8 or higher.Try using the latest QtSDK from http://qt-project.org")
MESSAGE("DEBUG: QT4_FOUND: ${QT4_FOUND} QT_MULTIMEDIA_FOUND: ${QT_QTMULTIMEDIA_FOUND} QT_MOBILITY_FOUND: ${QTMOBILITY_FOUND}")
SET(MANYEARS_GUI_DISABLED TRUE)
endif(QT4_FOUND AND (QT_QTMULTIMEDIA_FOUND OR QTMOBILITY_FOUND))
ELSE (NOT MANYEARS_GUI_DISABLED)
MESSAGE("ManyEars GUI disabled.")
ENDIF (NOT MANYEARS_GUI_DISABLED)
#Files excluded from package
set(CPACK_SOURCE_IGNORE_FILES
"build"
"bin"
${CPACK_SOURCE_IGNORE_FILES}
".svn"
)
#include files
(...)
IF (UNIX)
#########################################
# Packaging stuff for sources (All UNIX)
#########################################
SET(CPACK_SOURCE_GENERATOR "TGZ")
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING.TXT")
SET(CPACK_PACKAGE_NAME "ManyEars")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "ManyEars")
SET(CPACK_PACKAGE_VENDOR "Francois Grondin, Dominic Letourneau")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.TXT")
SET(CPACK_PACKAGE_CONTACT "blablablabla")
(...)
ENDIF(UNIX)
(...)
INCLUDE(CPack)
This is confusing me, shouldn't the OpenGL library be installed?
This is confusing me, shouldn't the OpenGL library be installed?
It's not complaining about OpenGL. It's complainting about Qt's OpenGL module QtOpenGL which is a different thing. Most likely your custom build of Qt doesn't include the QtOpenGL module. You've to go back building Qt and take extra care that you enable build of the QtOpenGL module.
After some research I found out that I needed to install some development packages if I was compiling from the source code.
apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libx11-xcb-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev
When configuring the Qt source code I had forgot to specify that I wanted to install the OpenGL module and the Multimedia Kit. I just naturally ran "configure" without any options and hoped for the best.
./configure --help
Specifies that I needed -multimedia and -opengl.
When I executed configure with the correct options the issue was resolved.
./configure -multimedia -opengl
Note that the multimedia kit needs gstreamer installed.

Qt 4.5.2 - linux - change library root

I have 2 versions of Qt for different arm devices and different toolchains: Qt 4.5.2 and Qt 4.7.3. Both versions are supposed to be placed in /opt/onyx/arm directory :(
The following error is occurred if I move the 1st Qt build in another directory (/usr/arm-marvell-linux-gnueabi) and run qmake:
#!/bin/sh
export QTDIR=/usr/arm-marvell-linux-gnueabi
/usr/arm-marvell-linux-gnueabi/bin/qmake -o Makefile.qt.onyx.a6x -spec qws/arm-marvell-linux-gnueabi-g++ project.pro
./run_qmake1.sh
Could not find mkspecs for your QMAKESPEC(qws/arm-marvell-linux-gnueabi-g++) after trying:
/opt/onyx/arm/mkspecs
Error processing project file: project.pro
What could be the issue and how can I resolve the /opt/onyx/arm conflict?
I would recommend grepping through /usr/arm-marvell-linux-gnueabi for any references to /opt/onyx. If you can't successfully change them (because they're in a binary), you could use symlinks to switch toolchains as needed.

OpenGL with QT: /usr/lib/libQtOpenGL.so not found

I am trying to use an example application which uses OpenGL in QT, but when compiling I ger the following error:
:-1: error: error: /usr/lib/libQtOpenGL.so: No such file or directory
I do have the line QT += opengl in my pro file, so I was wondering what the problem might be - is this an option I should have set when I initially compiled QT?
(On Ubuntu 11.10)
It turns out I did have the file on my system, but it had been put in /usr/lib/x86_64-linux-gnu/ for some reason. So I ran:
sudo cp /usr/lib/x86_64-linux-gnu/libQtOpenGL.so /usr/lib
at the terminal, and all is well.

Resources