编译 Qt 及 Qvfb 问题出现解决实例

移动开发
本文介绍的是编译 Qt 及 Qvfb 问题出现解决实例,有关解决方案本文又详细介绍,先来看内容。

编译 Qt Qvfb 问题出现解决实例是本文要介绍的内容,有关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 要装两个包:

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

3、编译qvfb遇到的问题

一定要用qmake

转载,和他遇到的问题一样,解决方法就是参照他的

译结束后我尝试的步骤如下: (着急的直接看最后几行!!)

1、进入qvfb源码目录:

  1. # cd /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb 

2、执行qmake生成pro工程:

  1. # /home/src/qt-x11-opensource-src-4.4.3/bin/qmake -project 

3、执行qmake生成Makefile

  1. # /home/src/qt-x11-opensource-src-4.4.3/bin/qmake 

4、编译make

  1. # make 

有错误:

  1. g++ -c -pipe -g -O2 -Wall -W -D_REENTRANT -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LI
  2. -DQT_SHARED -I../../mkspecs/linux-g++ -I. -I../../include/QtCore -I../../include/QtCore -I../../include/QtGui 
  3. -I../../include/QtGui -I../../include -I. -I.moc/release-shared -I.uic/release-shared -o .obj/release-shared/qvfb.o qvfb.cpp  
  4. qvfb.cpp:47:24: 错误:deviceskin.h:没有那个文件或目录  
  5. qvfb.cpp: In member function ‘void QVFb::init(int, int, int, int, int, const QString&)’:  
  6. qvfb.cpp:247: 警告:检测到调用 delete 运算符时可能出现的问题:  
  7. qvfb.cpp:247: 警告:invalid use of undefined type ‘struct DeviceSkin’  
  8. qvfb.h:53: 警告:forward declaration of ‘struct DeviceSkin’  
  9. qvfb.cpp:247: 附注:析构函数和类特定的 delete 运算符均不会被调用,即使它们在类定义时已经声明。  
  10. qvfb.cpp:257: 错误:‘DeviceSkinParameters’ 在此作用域中尚未声明  
  11. qvfb.cpp:257: 错误:expected `;'' before ‘parameters’  
  12. qvfb.cpp:259: 错误:‘parameters’ 在此作用域中尚未声明  
  13. qvfb.cpp:259: 错误:‘DeviceSkinParameters’ is not a class or namespace  
  14. qvfb.cpp:260: 错误:invalid use of undefined type ‘struct DeviceSkin’  
  15. qvfb.h:53: 错误:forward declaration of ‘struct DeviceSkin’  
  16. qvfb.cpp:261: 错误:对 ‘QVFb::connect(DeviceSkin*&, const char [13], QVFb* const, const char [13])’ 的调用没有匹配的函数  
  17. ../../include/QtCore/../../src/corelib/kernel/qobject.h:197: 附注:备选为: static bool QObject::connect
  18. (const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)  
  19. ../../include/QtCore/../../src/corelib/kernel/qobject.h:302: 附注:         bool QObject::connect
  20. (const QObject*, const char*, const char*, Qt::ConnectionType) const  
  21. qvfb.cpp:277: 错误:对 ‘QVFbX11View::QVFbX11View(int&, int&, int&, int&, QVFbAbstractView::Rotation&, DeviceSkin*&)’ 的调用没有匹配的函数  
  22. qvfbx11view.h:52: 附注:备选为: QVFbX11View::QVFbX11View(int, int, int, int, QVFbAbstractView::Rotation, QWidget*)  
  23. qvfbx11view.h:49: 附注:         QVFbX11View::QVFbX11View(const QVFbX11View&)  
  24. qvfb.cpp:280: 错误:对 ‘QVFbView::QVFbView(int&, int&, int&, int&, QVFbAbstractView::Rotation&, DeviceSkin*&)’ 的调用没有匹配的函数  
  25. qvfbview.h:109: 附注:备选为: QVFbView::QVFbView(int, int, int, int, QVFbAbstractView::Rotation, QWidget*)  
  26. qvfbview.h:106: 附注:         QVFbView::QVFbView(const QVFbView&)  
  27. qvfb.cpp:281: 错误:invalid use of undefined type ‘struct DeviceSkin’  
  28. qvfb.h:53: 错误:forward declaration of ‘struct DeviceSkin’  
  29. qvfb.cpp:284: 错误:对 ‘QVFb::connect(DeviceSkin*&, const char [37], QVFbAbstractView*&, const char [37])’ 的调用没有匹配的函数  
  30. ../../include/QtCore/../../src/corelib/kernel/qobject.h:197: 附注:备选为: static bool QObject::connect
  31. (const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)  
  32. ../../include/QtCore/../../src/corelib/kernel/qobject.h:302: 附注:         bool QObject::connect
  33. (const QObject*, const char*, const char*, Qt::ConnectionType) const  
  34. qvfb.cpp:285: 错误:对 ‘QVFb::connect(DeviceSkin*&, const char [39], QVFbAbstractView*&, const char [39])’ 的调用没有匹配的函数  
  35. ../../include/QtCore/../../src/corelib/kernel/qobject.h:197: 附注:备选为: static bool QObject::connect
  36. (const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)  
  37. ../../include/QtCore/../../src/corelib/kernel/qobject.h:302: 附注: bool QObject::connect
  38. (const QObject*, const char*, const char*, Qt::ConnectionType) const  
  39. qvfb.cpp:287: 错误:invalid use of undefined type ‘struct DeviceSkin’  
  40. qvfb.h:53: 错误:forward declaration of ‘struct DeviceSkin’  
  41. qvfb.cpp:289: 错误:对 ‘QVFb::setCentralWidget(DeviceSkin*&)’ 的调用没有匹配的函数  
  42. ../../include/QtGui/../../src/gui/widgets/qmainwindow.h:116: 附注:备选为: void QMainWindow::setCentralWidget(QWidget*)  
  43. qvfb.cpp:302: 错误:对 ‘QVFbX11View::QVFbX11View(int, int, int, int&, QVFbAbstractView::Rotation&, DeviceSkin*&)’ 的调用没有匹配的函数  
  44. qvfbx11view.h:52: 附注:备选为: QVFbX11View::QVFbX11View(int, int, int, int, QVFbAbstractView::Rotation, QWidget*)  
  45. qvfbx11view.h:49: 附注:         QVFbX11View::QVFbX11View(const QVFbX11View&)  
  46. qvfb.cpp:305: 错误:对 ‘QVFbView::QVFbView(int, int, int, int&, QVFbAbstractView::Rotation&, DeviceSkin*&)’ 的调用没有匹配的函数  
  47. qvfbview.h:109: 附注:备选为: QVFbView::QVFbView(int, int, int, int, QVFbAbstractView::Rotation, QWidget*)  
  48. qvfbview.h:106: 附注:         QVFbView::QVFbView(const QVFbView&)  
  49. qvfb.cpp:306: 错误:invalid use of undefined type ‘struct DeviceSkin’  
  50. qvfb.h:53: 错误:forward declaration of ‘struct DeviceSkin’  
  51. qvfb.cpp: In member function ‘void QVFb::enableCursor(bool)’:  
  52. qvfb.cpp:379: 错误:invalid use of undefined type ‘struct DeviceSkin’  
  53. qvfb.h:53: 错误:forward declaration of ‘struct DeviceSkin’  
  54. qvfb.cpp: In member function ‘void QVFb::setZoom(double)’:  
  55. qvfb.cpp:453: 错误:invalid use of undefined type ‘struct DeviceSkin’  
  56. qvfb.h:53: 错误:forward declaration of ‘struct DeviceSkin’  
  57. qvfb.cpp: In member function ‘void QVFb::skinConfigChosen(int)’:  
  58. qvfb.cpp:771: 错误:‘DeviceSkinParameters’ 在此作用域中尚未声明  
  59. qvfb.cpp:771: 错误:expected `;'' before ‘parameters’  
  60. qvfb.cpp:773: 错误:‘parameters’ 在此作用域中尚未声明  
  61. qvfb.cpp:773: 错误:‘DeviceSkinParameters’ is not a class or namespace  
  62. 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文件夹下。再编译:

#p#

编译没有问题,连接出错:

  1. .obj/release-shared/qvfb.o: In function `QVFb::setZoom(double)'':  
  2. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:453: undefined reference to `DeviceSkin::setTransform(QMatrix const&)''  
  3. .obj/release-shared/qvfb.o: In function `QVFb::enableCursor(bool)'':  
  4. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:379: undefined reference to `DeviceSkin::hasCursor() const''  
  5. .obj/release-shared/qvfb.o: In function `QVFb::skinConfigChosen(int)'':  
  6. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:773: undefined reference to `DeviceSkinParameters::read(QString const&, 
  7. DeviceSkinParameters::ReadMode, QString*)''  
  8. .obj/release-shared/qvfb.o: In function `QVFb::init(int, int, int, int, int, QString const&)'':  
  9. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:259: undefined reference to `DeviceSkinParameters::read(QString const&, 
  10. DeviceSkinParameters::ReadMode, QString*)''  
  11. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:260: undefined reference to `DeviceSkin::DeviceSkin(DeviceSkinParameters const&, 
  12. QWidget*)''  
  13. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:281: undefined reference to `DeviceSkin::setView(QWidget*)''  
  14. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:297: undefined reference to `DeviceSkinParameters::hasSecondaryScreen() const''  
  15. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:298: undefined reference to `DeviceSkinParameters::secondaryScreenSize() const''  
  16. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/qvfb.cpp:306: undefined reference to `DeviceSkin::setSecondaryView(QWidget*)''  
  17. .obj/release-shared/x11keyfaker.o: In function `X11KeyFaker::sendKeyEvent(int, bool)'':  
  18. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:475: undefined reference to `XTestFakeKeyEvent''  
  19. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:459: undefined reference to `XTestFakeKeyEvent''  
  20. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:468: undefined reference to `XTestFakeKeyEvent''  
  21. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:454: undefined reference to `XTestFakeKeyEvent''  
  22. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:447: undefined reference to `XTestFakeKeyEvent''  
  23. .obj/release-shared/x11keyfaker.o:/home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:459: 
  24. more undefined references to `XTestFakeKeyEvent'' follow  
  25. .obj/release-shared/x11keyfaker.o: In function `X11KeyFaker::connect()'':  
  26. /home/src/qt-x11-opensource-src-4.4.3/tools/qvfb/x11keyfaker.cpp:544: undefined reference to `XTestQueryExtension''  
  27. collect2: ld 返回 1  
  28. 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函数连接的问题依旧。

最后在参考http://www.linuxquestions.org/questions/programming-9/strange-header-problem-228356/

在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

终于搞定了

小结:编译 Qt Qvfb 问题出现解决实例的内容介绍完了,希望本文对你有所帮助。

责任编辑:zhaolei 来源: 互联网
相关推荐

2011-06-30 14:44:16

QT Qvfb Embedded

2011-06-29 17:00:26

QT 静态编译 Debug

2011-07-01 13:31:29

Ubuntu Linux QVFB

2011-07-04 10:56:10

Qt 移植 编译

2010-06-12 12:46:04

Grub Rescue

2010-01-15 10:31:19

Linux编译

2011-08-24 17:41:16

MySQL死锁

2011-07-04 10:09:19

Qt Creator BUG

2011-07-05 14:29:44

Ubuntu QT Mysql

2017-06-14 22:11:57

数据库MySQL死锁

2010-06-01 14:51:45

MySQL驱动

2011-08-23 14:18:13

LUA 5.1编译vs2005

2011-07-04 15:13:31

QT MPlayer 移植

2011-06-21 16:13:51

Qt Oracle 驱动

2011-07-05 14:23:07

QT MySQL 驱动

2011-06-22 17:49:35

Linux Qt 串口

2011-04-29 11:02:31

激光打印机

2009-07-10 17:16:39

MyEclipse不编

2011-06-29 18:02:58

Qt 中文 翻译

2011-06-13 16:16:32

Qt 中文问题
点赞
收藏

51CTO技术栈公众号