sudo apt-get install libxtst-dev
sudo apt-get install libxrender-dev
今天编译了一个应用程序,其中要用到 QtMultimedia的库文件,出现错误如下:
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DWITH_ENGINE -DWITH_MOTION_RECTS -DDUAL_RENDERING -DNO_DEWARP_SETTING -DQT_NO_DEBUG -DQT_MULTIMEDIA_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4/QtMultimedia -I/usr/include/qt4 -I../include -I../lib -I/usr/X11R6/include -I. -I. -o main.o main.cpp
In file included from ptzsettings.h:6:0,
from generalsettings.h:24,
from mainwindow.h:25,
from main.cpp:21:
displaychannel.h:24:46: fatal error: QtMultimedia/QAbstractVideoSurface: No such file or directory
查找原因,ubuntu10.04支持qt4 的4.6.2,libqt4-dev (4:4.6.2-0ubuntu5) 可以通过sudo apt-get install libqt4-dev 来更新,但是这里只吃之4.6.2
http://packages.trisquel.info/taranis/i386/libqt4-dev 这里面有QtMultimedia的支持,而12.04变成了4.8.1没有lib库的支持及相应的文件支持,因此需要自行编译:
download this version:
qt-everywhere-opensource-src-4.8.1.tar.gz
wget http://mirrors.ustc.edu.cn/qtproject/archive/qt/4.8/4.8.1/qt-everywhere-opensource-src-4.8.1.tar.gz -P /your place
tar -zxvfqt-everywhere-opensource-src-4.8.1.tar.gz -C /yourplace
cd /yourplace/qt-everywhere-opensource-src-4.8.1
./configure
选择open source及编译
make
sudo make install
#If success, the below DLL file is OK.Generally speaking we will use # theDLL to lunch our fishy app. Also the fishy will use the #libQtMultimedia
ln -s /usr/local/Trolltech/Qt-4.8.1/include/QtMultimedia /usr/include/qt4/QtMultimedia
// another way is cp the file to the related directory.
sudo cp ./include/QtMultimedia /usr/include/qt4
ln –s ./source/QtMultimedia /usr/src/multimedia
// another way is cp the file to the related directory.
sudocp ./source/QtMultimedia /usr/src/multimedia
ln –s ./libQtMultimedia.so /usr/lib/libQtMultimedia.so
// another way is cp the file to the related directory.
sudo cp./lib/libQtMultimedia.so.4.8.1 /usr/lib
sudoln -s /usr/lib/libQtMultimedia.so.4.8.1./libQtMultimedia.so.4.8
sudoln -s /usr/lib/libQtMultimedia.so.4.8.1./libQtMultimedia.so
然后运行重新编译自己的应用程序,编译通过~~~
当编译遇到以下问题的时候,需要用最新的qt版本:
g++ -c -pipe -O2 -Wall -W-D_REENTRANT -DWITH_ENGINE -DWITH_MOTION_RECTS -DDUAL_RENDERING-DVERSION=\"3.0\" -DQT_NO_DEBUG -DQT_MULTIMEDIA_LIB -DQT_OPENGL_LIB-DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I.-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL-I/usr/include/qt4/QtMultimedia -I/usr/include/qt4 -I../../../lib/mxuvc/include-I../../../lib/ePTZ -I../include -I/usr/X11R6/include -I. -I. -o audiorecord.oaudiorecord.cpp
In file included fromaudiorecord.cpp:3:
ui_audiorecord.h: Inmember function ‘void Ui_AudioRecord::retranslateUi(QWidget*)’:
ui_audiorecord.h:174:error: ‘class QLineEdit’ has no member named ‘setPlaceholderText’
make[1]: ***[audiorecord.o] Error 1
make[1]: Leaving directory`/home/kingdz/work/gc6500-5.0.5/condorsw/host/apps/fishy/src'
make: *** [src/all] Error2
当遇到该问题的时候,需要下载最新的的qt4版本,因为系统自带的libqt4版本的版本比较低,一些函数没有定义,如上述错误:
需要自行下载qt44.8以上的版本:参见wget的网址http://mirrors.ustc.edu.cn/qtproject/archive/qt/4.8/
QTlib要4.8以上的版本,而有些系统自带的不是4.8的系统,因此需要安装4.8以上的系统。