歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 9.04下編譯QT及Qvfb遇到的問題

Ubuntu 9.04下編譯QT及Qvfb遇到的問題

日期:2017/2/28 16:44:38   编辑:Linux教程

Ubuntu 9.04下編譯QT及Qvfb遇到問題的解決:

1、/usr/bin/ld: cannot find -lXtst這個問題是庫名稱的問題,一般庫後都有.so.6等數字,而qt編譯時,這樣的庫名識別不了,解決辦法是建立一個不帶數字後最的庫名的軟連接
如這個問題:sudo ln -s /usr/lib/libXtst.so.6 /usr/lib/libXtst.so,然後ok

2、找不到XTest.h和XInput.h 要裝兩個包:

XTest.h----libext-dev
XInput.h ---libxi-dev

3、編譯qvfb遇到的問題

一定要用qmake
轉載,和他遇到的問題一樣,解決方法就是參照他的
譯結束後我嘗試的步驟如下: (著急的直接看最後幾行!!)

1.進入qvfb源碼目錄:
# cd /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb
2.執行qmake生成pro工程:
# /home/src/qt-x11-opensource-src-4.4.3/bin/qmake -project
3.執行qmake生成Makefile
# /home/src/qt-x11-opensource-src-4.4.3/bin/qmake
4.編譯make
# make

有錯誤:
g++ -c -pipe -g -O2 -Wall -W -D_REENTRANT -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../mkspecs/linux-g++ -I. -I../../include/QtCore -I../../include/QtCore -I../../include/QtGui -I../../include/QtGui -I../../include -I. -I.moc/release-shared -I.uic/release-shared -o .obj/release-shared/qvfb.o qvfb.cpp
qvfb.cpp:47:24: 錯誤:deviceskin.h:沒有那個文件或目錄
qvfb.cpp: In member function ‘void QVFb::init(int, int, int, int, int, const QString&)’:
qvfb.cpp:247: 警告:檢測到調用 delete 運算符時可能出現的問題:
qvfb.cpp:247: 警告:invalid use of undefined type ‘struct DeviceSkin’
qvfb.h:53: 警告:forward declaration of ‘struct DeviceSkin’
qvfb.cpp:247: 附注:析構函數和類特定的 delete 運算符均不會被調用,即使它們在類定義時已經聲明。
qvfb.cpp:257: 錯誤:‘DeviceSkinParameters’ 在此作用域中尚未聲明
qvfb.cpp:257: 錯誤:expected `;'' before ‘parameters’
qvfb.cpp:259: 錯誤:‘parameters’ 在此作用域中尚未聲明
qvfb.cpp:259: 錯誤:‘DeviceSkinParameters’ is not a class or namespace
qvfb.cpp:260: 錯誤:invalid use of undefined type ‘struct DeviceSkin’
qvfb.h:53: 錯誤:forward declaration of ‘struct DeviceSkin’
qvfb.cpp:261: 錯誤:對 ‘QVFb::connect(DeviceSkin*&, const char [13], QVFb* const, const char [13])’ 的調用沒有匹配的函數
../../include/QtCore/../../src/corelib/kernel/qobject.h:197: 附注:備選為: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
../../include/QtCore/../../src/corelib/kernel/qobject.h:302: 附注: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
qvfb.cpp:277: 錯誤:對 ‘QVFbX11View::QVFbX11View(int&, int&, int&, int&, QVFbAbstractView::Rotation&, DeviceSkin*&)’ 的調用沒有匹配的函數
qvfbx11view.h:52: 附注:備選為: QVFbX11View::QVFbX11View(int, int, int, int, QVFbAbstractView::Rotation, QWidget*)
qvfbx11view.h:49: 附注: QVFbX11View::QVFbX11View(const QVFbX11View&)
qvfb.cpp:280: 錯誤:對 ‘QVFbView::QVFbView(int&, int&, int&, int&, QVFbAbstractView::Rotation&, DeviceSkin*&)’ 的調用沒有匹配的函數
qvfbview.h:109: 附注:備選為: QVFbView::QVFbView(int, int, int, int, QVFbAbstractView::Rotation, QWidget*)
qvfbview.h:106: 附注: QVFbView::QVFbView(const QVFbView&)
qvfb.cpp:281: 錯誤:invalid use of undefined type ‘struct DeviceSkin’
qvfb.h:53: 錯誤:forward declaration of ‘struct DeviceSkin’
qvfb.cpp:284: 錯誤:對 ‘QVFb::connect(DeviceSkin*&, const char [37], QVFbAbstractView*&, const char [37])’ 的調用沒有匹配的函數
../../include/QtCore/../../src/corelib/kernel/qobject.h:197: 附注:備選為: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
../../include/QtCore/../../src/corelib/kernel/qobject.h:302: 附注: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
qvfb.cpp:285: 錯誤:對 ‘QVFb::connect(DeviceSkin*&, const char [39], QVFbAbstractView*&, const char [39])’ 的調用沒有匹配的函數
../../include/QtCore/../../src/corelib/kernel/qobject.h:197: 附注:備選為: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
../../include/QtCore/../../src/corelib/kernel/qobject.h:302: 附注: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
qvfb.cpp:287: 錯誤:invalid use of undefined type ‘struct DeviceSkin’
qvfb.h:53: 錯誤:forward declaration of ‘struct DeviceSkin’
qvfb.cpp:289: 錯誤:對 ‘QVFb::setCentralWidget(DeviceSkin*&)’ 的調用沒有匹配的函數
../../include/QtGui/../../src/gui/widgets/qmainwindow.h:116: 附注:備選為: void QMainWindow::setCentralWidget(QWidget*)
qvfb.cpp:302: 錯誤:對 ‘QVFbX11View::QVFbX11View(int, int, int, int&, QVFbAbstractView::Rotation&, DeviceSkin*&)’ 的調用沒有匹配的函數
qvfbx11view.h:52: 附注:備選為: QVFbX11View::QVFbX11View(int, int, int, int, QVFbAbstractView::Rotation, QWidget*)
qvfbx11view.h:49: 附注: QVFbX11View::QVFbX11View(const QVFbX11View&)
qvfb.cpp:305: 錯誤:對 ‘QVFbView::QVFbView(int, int, int, int&, QVFbAbstractView::Rotation&, DeviceSkin*&)’ 的調用沒有匹配的函數
qvfbview.h:109: 附注:備選為: QVFbView::QVFbView(int, int, int, int, QVFbAbstractView::Rotation, QWidget*)
qvfbview.h:106: 附注: QVFbView::QVFbView(const QVFbView&)
qvfb.cpp:306: 錯誤:invalid use of undefined type ‘struct DeviceSkin’
qvfb.h:53: 錯誤:forward declaration of ‘struct DeviceSkin’
qvfb.cpp: In member function ‘void QVFb::enableCursor(bool)’:
qvfb.cpp:379: 錯誤:invalid use of undefined type ‘struct DeviceSkin’
qvfb.h:53: 錯誤:forward declaration of ‘struct DeviceSkin’
qvfb.cpp: In member function ‘void QVFb::setZoom(double)’:
qvfb.cpp:453: 錯誤:invalid use of undefined type ‘struct DeviceSkin’
qvfb.h:53: 錯誤:forward declaration of ‘struct DeviceSkin’
qvfb.cpp: In member function ‘void QVFb::skinConfigChosen(int)’:
qvfb.cpp:771: 錯誤:‘DeviceSkinParameters’ 在此作用域中尚未聲明
qvfb.cpp:771: 錯誤:expected `;'' before ‘parameters’
qvfb.cpp:773: 錯誤:‘parameters’ 在此作用域中尚未聲明
qvfb.cpp:773: 錯誤:‘DeviceSkinParameters’ is not a class or namespace
make: *** [.obj/release-shared/qvfb.o] 錯誤 1
差點就放棄了。後來仔細看了一下編譯錯誤。估計主要是差個頭文件:
qvfb.cpp:47:24: 錯誤:deviceskin.h:沒有那個文件或目錄
一般差頭文件會導致cpp文件中很多數據結構和常量沒有定義。找到頭文件deviceskin.h在qt-x11-opensource-src-4.4.3/tools/shared/deviceskin/下面。拷貝到qvfb文件夾下。再編譯:

編譯沒有問題,連接出錯:

.obj/release-shared/qvfb.o: In function `QVFb::setZoom(double)'':
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:453: undefined reference to `DeviceSkin::setTransform(QMatrix const&)''
.obj/release-shared/qvfb.o: In function `QVFb::enableCursor(bool)'':
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:379: undefined reference to `DeviceSkin::hasCursor() const''
.obj/release-shared/qvfb.o: In function `QVFb::skinConfigChosen(int)'':
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:773: undefined reference to `DeviceSkinParameters::read(QString const&, DeviceSkinParameters::ReadMode, QString*)''
.obj/release-shared/qvfb.o: In function `QVFb::init(int, int, int, int, int, QString const&)'':
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:259: undefined reference to `DeviceSkinParameters::read(QString const&, DeviceSkinParameters::ReadMode, QString*)''
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:260: undefined reference to `DeviceSkin::DeviceSkin(DeviceSkinParameters const&, QWidget*)''
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:281: undefined reference to `DeviceSkin::setView(QWidget*)''
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:297: undefined reference to `DeviceSkinParameters::hasSecondaryScreen() const''
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:298: undefined reference to `DeviceSkinParameters::secondaryScreenSize() const''
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:306: undefined reference to `DeviceSkin::setSecondaryView(QWidget*)''
.obj/release-shared/x11keyfaker.o: In function `X11KeyFaker::sendKeyEvent(int, bool)'':
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:475: undefined reference to `XTestFakeKeyEvent''
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:459: undefined reference to `XTestFakeKeyEvent''
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:468: undefined reference to `XTestFakeKeyEvent''
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:454: undefined reference to `XTestFakeKeyEvent''
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:447: undefined reference to `XTestFakeKeyEvent''
.obj/release-shared/x11keyfaker.o:/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:459: more undefined references to `XTestFakeKeyEvent'' follow
.obj/release-shared/x11keyfaker.o: In function `X11KeyFaker::connect()'':
/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:544: undefined reference to `XTestQueryExtension''
collect2: ld 返回 1
make: *** [qvfb] 錯誤 1

能看出來有兩個方面的錯誤,一個是DeviceSkinParameters類的函數連接,另一個XTestFakeKeyEvent函數的問題。
我嘗試的解決辦法:

將qt-x11-opensource-src-4.4.3/tools/shared/deviceskin/下deviceskin.h,deviceskin.cpp都拷到qvfb文件夾下面,重新生成pro工程、Makefile文件,再執行make.
這下子DeviceSkinParameters類的函數連接的問題解決了。XTestFakeKeyEvent函數連接的問題依舊。

最後在Makefile文件中LIBS裡面添加-lXtst選項。。 再次make。 OK!!
生成的qvfb正確運行。

總結起來解決辦法是:

1。復制deviceskin.h,deviceskin.cpp到qvfb文件下。
2。在qvfb文件夾下手動生成qvfb工程。
3。修改Makefile 中 LIBS 選項: 添加 -lXtst選項。
編譯...

這裡要注意,把deviceskin.h,deviceskin.cpp復制到qvfb文件下要重新生成project文件
即用qmake -project
終於搞定了
學到了不少東西,前幾天學到的東西有學以致用,鍛煉了下,愉快���。。

Copyright © Linux教程網 All Rights Reserved