qtopia2.2.0編譯成功,分享一下經驗

經過一段漫長而痛苦的過程(幾次差點就要放棄)之後,今天qtopia2.2.0pc版本和ARM-LINUX版本都終於編譯成功了,下面我和大家分享一下pc機版本的qtopia2.2.0編譯過程中的遇到的錯誤及其解決辦法,希望與大家一起進步。(arm-linux版本的編譯參照飛凌提供的6410的qt移植視頻中的五和六,先編譯第三方庫,按照視頻上來就沒有問題,編譯完第三方庫以後,剩下的就和pc版本的相差無幾了)

環境ubuntu10.10   
編譯器: gcc version 4.4.5  
主機:奔四   
內存:512+256M    
VMware版本:7.0

注意事項:
     在編譯之前先確保你的ubuntu系統中有X11的SDK庫,Qtopia編譯過程中需要使用X11SDK裏面的一些頭文件,使用以下命令,即可完成安裝:    
     apt-get install libx11-dev libxext-dev libxtst-dev

   另外,在修改完第一處錯誤,重新編譯之前,先修改一下build腳本文件,因爲重新執行build命令,該腳本會把剛纔編譯中的qtopia-free-2.2.0文件夾刪除,重新解壓,形成新的qtopia-free-2.2.0,開始編譯,這樣剛纔的修改就失去意義了。修改build腳本的方法如下:
      將  rm -fr qtopia-free-2.2.0
          tar xfvz qtopia-free-2.2.0.tar.gz 這兩條語句的前面分別加上#  ,註釋掉,保存退出,重新執行  ./build


在編譯過程中會出現很多的錯誤,包括飛凌提供的ok6410 QT移植百科全書裏面的,但是手冊裏面羅列的不全,下面我將我在編譯過程實際遇到的編譯錯誤及其解決辦法寫一下(其中的一些錯誤實際中沒有遇到,是從網上搜集的,供朋友們參考):
  
  錯誤一:
        /usr/bin/ld: cannot find -lXmu
        collect2: ld returned 1 exit status
  錯誤二:
         Creating pngscale...make[1]: Entering directory `/root/yizhi/qtopia-free-2.2.0/qtopia/util/pngscale'
..make[1]: *** [../../bin/pngscale] Error 1
make[1]: Leaving directory `/root/yizhi/qtopia-free-2.2.0/qtopia/util/pngscale'
Failed to make pngscale
    分析:
         這是因爲沒有安裝uuid和Xmu,因爲在編譯qtopia2.2.0的過程中需要安裝工具uuid(Universally Unique Identifier,)和 xmu庫文件。
    解決辦法:
            
           apt-get install  uuid-dev 
           apt-get install libxmu-dev libxmu6

錯誤三:
      external/clearsilver/cgi/cgi.c:22: fatal error: zlib.h: No such file or directory
       compilation terminated.
      make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] Error 1

  解決:
        在ubuntu裏,zlib叫zlib1g,相應的zlib-devel叫zlib1g.dev

        sudo apt-get install zlib1g-dev

錯誤四:
      /usr/bin/ld: cannot find -lz
      collect2: ld returned 1 exit status
      make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1

   解決方法:
       sudo apt-get install lib32z1-dev

錯誤五:
     bison -d  -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp      frameworks/base/tools/aidl/aidl_language_y.y
     /bin/bash: bison: command not found
     make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127

    解決方法:
     sudo apt-get install bison

錯誤六:
      Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
      /bin/bash: flex: command not found
      make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127

    解決方法:
      sudo apt-get install flex
            
錯誤七:
      /usr/bin/ld: cannot find -lncurses
      collect2: ld returned 1 exit status
     make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1

解決方法:
     sudo apt-get install lib32ncurses5-dev

錯誤八:
    prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:55: fatal error: X11/Xlib.h: No such file     or directory
    compilation terminated.
    make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/main-common.o] Error 1

解決方法:
    sudo apt-get install libx11-dev 


錯誤九:
     sh: gperf: not found
     calling gperf failed: 32512 at ./makeprop.pl line 96.
     make: ***  [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h'

解決方法:
     sudo apt-get install gperf 

錯誤十:open函數參數不夠  

    /usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open   with O_CREAT in second argument needs 3 arguments

  解決辦法:
     參見ok6410移植百科全書。

錯誤十一:使用未定義的類
  
     error: ‘QWSInputMethod’ has not been declared
  解決辦法:
       參見ok6410移植百科全書。 (注: 該文件中使用了這兩個類,C++允許在文件中這樣聲明其他地方定義的類,減少頭文件的相互包含關係,加快編譯速度)


錯誤十二:缺少頭文件
        asm/page.h: No such file or directory
  解決辦法:
        參見ok6410移植百科全書。


錯誤十三:類型轉換錯誤
      home/work/armqt/qtlibsource/qt-x11/include/qvalue stack.h: In member function 'T QValueStack<T>::pop() [with T = QMap<QString, QString>]': 
xml/qxml.cpp:513:   instantiated from here 
  /home/work/armqt/qtlibsource/qt-x11/include/qvalue stack.h:57: 錯誤:不能從'QValueListIterator<QMap<QString, QString> >'轉換到'const char*',爲實參'1'(屬於'int remove(const char*)') 
/home/work/armqt/qtlibsource/qt-x11/include/qvalue stack.h: In member function 'T QValueStack<T>::pop() [with T = QString]': 
xml/qxml.cpp:2502:   instantiated from here 
  /home/work/armqt/qtlibsource/qt-x11/include/qvalue stack.h:57: 錯誤:不能從'QValueListIterator<QString>'轉換到'const char*',爲實參'1'(屬於'int remove(const char*)')
    解決辦法:
         參見ok6410移植百科全書。

錯誤十四:沒有找到uic工具  錯誤提示:

    make[5]: /root/yizhi/host/qtopia-free-2.2.0/qt2/bin/uic: Command not found
    make[5]: *** [../../../include/qtopia/private/passwordbase_p.h] Error 127
   解決辦法:
         cd到你的qtopia-free-2.2.0目錄下, find ./  -name uic 會看到其他的目錄下已經有了uic,我把qt3/bin 目錄下的uic拷貝到 qt2/bin下面,即可 
       (注:我在實際操作過程中,一開始報出這個錯誤,但是將其他的錯誤改完之後,這個錯誤也就自動消失了,我是菜鳥,不知道怎麼回事, )


錯誤十五: 指針類型轉換出錯:
  backend/vobject.cpp: In function ‘VObject* addGroup(VObject*, const char*)’:
  backend/vobject.cpp:419: error: invalid conversion from ‘const char*’ to ‘char*’
  backend/vobject.cpp: In function ‘void writeEncString(OFi

解決辦法:
  修改 qtopia-free-2.2.0/qtopia/src/libraries/qtopia/backend/vobject.cpp 文件419行
   char *dot = strrchr(g,'.');    修改爲 char *dot = (char *)strrchr(g,'.');



在編譯過程中還出現了類似的錯誤
     wavplugin.cpp:435 : error: invalid conversion from 'const char*' to 'char*'
   解決辦法
        修改qtopia-free-2.2.0/qtopia/src/plugins/codes/wavplugin/wavplugin.cpp文件的第435行
       修改方法如上


錯誤十六:編譯器找不到QSizePolicy類的五個參數的構造函數

   ui/release-shared/passwordbase_p.cpp:35: error: no matching function for call to ‘QSizePolicy:SizePolicy(QSizePolicy::SizeType, QSizePolicy::SizeType, int, int, bool)’
/root/yizhi/host/qtopia-free-2.2.0/qt2/include/qsizepolicy.h:93: note: candidates are: QSizePolicy:SizePolicy(int)
/root/yizhi/host/qtopia-free-2.2.0/qt2/include/qsizepolicy.h:99: note:                 QSizePolicy:SizePolicy(QSizePolicy::SizeType, QSizePolicy::SizeType, bool)
/root/yizhi/host/qtopia-free-2.2.0/qt2/include/qsizepolicy.h:63: note:                 QSizePolicy:SizePolicy()
/root/yizhi/host/qtopia-free-2.2.0/qt2/include/qsizepolicy.h:46: note:                 QSizePolicy:SizePolicy(const QSizePolicy  & )

   解決辦法:

    qtopia-free-2.2.0/qtopia/src/libraries/qtopia/.ui/release-shared/passwordbase_p.cpp 文件中的38行位置
    prompt = new QLabel( this, "prompt" );
    prompt->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, 0, 0, prompt->sizePolicy().hasHeightForWidth() ) );

  修改爲:

    prompt = new QLabel( this, "prompt" );
    prompt->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, prompt->sizePolicy  ().hasHeightForWidth() ) );

  即去掉0,0 兩個參數 


錯誤十七(這是一大類錯誤,在編譯過程中會遇到很多):g++編譯器提示 有多餘的符號在成員函數前 ,有些編譯器規定C++成員函數前不需要再加這個類的名字

    thumbnailview_p.h: At global scope:
thumbnailview_p.h:81: error: extra qualification ‘ThumbnailItem::’ on member ‘paintItem’
make[5]: *** [.obj/release-shared/imageselector.o] Eopia/src

  解決辦法 :

      qtopia-free-2.2.0/qtopia/src/libraries/qtopia2/thumbnailview_p.h文件中第81行:

    修改 void ThumbnailItem::paintItem( QPainter*, const QColorGroup& ); 

    修改後  void  paintItem( QPainter*, const QColorGroup& ); 

  ** 繼續編譯後會出現類似的錯誤

abtable_p.h:276: error: extra qualification ‘PhoneTypeSelector::’ on member ‘addType’
make[5]: *** [.obj/release-shared/abtable.o] Error 1
make[5]: Leaving directory `/root/yizhi/host/qtopia-free-2.2.0/qtopia/src/libraries/qtopiapim'
make[4]: *** [all] Error 2
    解決辦法:去掉 PhoneTypeSelector::

繼續編譯:
     ../../../include/qtopia/pim/private/../../../../src/libraries/qtopiapim/numberentry_p.h: At global scope:
../../../include/qtopia/pim/private/../../../../src/libraries/qtopiapim/numberentry_p.h:106: error: extra qualification ‘NumberEntryDialog::’ on member ‘eventFilter’
make[5]: *** [.obj/release-shared/numberentry.o] Error 1
make[5]: Leaving directory `/root/yizhi/host/qtopia-free-2.2.0/qtopia/src/libraries/qtopiapim'
make[4]: *** [all] Error 2

解決辦法:去掉NumberEntryDialog::’

繼續編譯
  In file included from addressbook.cpp:40:
ablabel.h: At global scope:
ablabel.h:78: error: extra qualification ‘AbLabel::’ on member ‘decodeHref"

解決辦法:去掉‘AbLabel::’

 

繼續編譯
  In file include from minefiled.cpp:35
  minefiled.h:105: error: extra qualification 'MineFiled::' on member
  'setState'
  minefiled.h:106: error: extra qualification 'MineFiled::' on member
  'placeMines'

解決辦法:
      編輯 qtopia-free-2.2.0/qtopia/src/games/minesweep/minefiled.h
     修改106行和105行:  刪除'MineFiled::'即可


繼續編譯
     buttoneditordialog.h:56 error:extra qualification 'ButtonEditorDialog::' on member
    'actionFor'
   解決辦法:
       編輯qtopia-free-2.2.0/qtopia/src/settings/buttoneditor/buttoneditordialog.h
     將'ButtonEditorDialog::' 刪除即可



繼續編譯
     出現packagewizard.h:106:error: extra qualification 'PackageWizard::' on member
    'current'
    解決辦法
       編輯qtopia-free-2.2.0/qtopia/src/settings/qipkg/packagewizard.h
       將'PackageWizard::'刪除即可

繼續編譯
    出現  keboard.h:60 error:extra qualification 'KeboardPicks::' on member
    'KeboardPicks'
    解決辦法
       編輯qtopia-free-2.2.0/qtopia/src/plugins/inputmethods/keyboard/keyboard.h
       將第60行的'KeboardPicks::'刪除即可

繼續編譯
      還會出現類似的錯誤,如extra qualification 'PolishedDecoration::' 、'IMToolButton::'



錯誤十八:未經定義的構造函數錯誤提示

.ui/release-shared/emaildlg.cpp: In constructor ‘EmailDialogBase::EmailDialogBase(QWidget*, const char*, bool, uint)’:
.ui/release-shared/emaildlg.cpp:65: error: no matching function for call to ‘QSizePolicy:SizePolicy(QSizePolicy::SizeType, QSizePolicy::SizeType, int, int, bool)’
/root/yizhi/host/qtopia-free-2.2.0/qt2/include/qsizepolicy.h:93: note: candidates are: QSizePolicy:SizePolizePolicj4

     修改  qtopia-free-2.2.0/qtopia/src/applications/addressbook/.ui/release-shared/emaildlg.cpp  文件第65行
   
    okButton = new QPushButton( this, "okButton" );
    okButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, 0, 0, okButton->sizePolicy().hasHeightForWidth() ) );
    Layout2->addWidget( okButton );

    cancelButton = new QPushButton( this, "cancelButton" );
    cancelButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, 0, 0, cancelButton->sizePolicy().hasHeightForWidth() ) );
    Layout2->addWidget( cancelButton );

  修改爲


okButton = new QPushButton( this, "okButton" );
    okButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,okButton->sizePolicy().hasHeightForWidth() ) );
    Layout2->addWidget( okButton );

    cancelButton = new QPushButton( this, "cancelButton" );
    cancelButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,cancelButton->sizePolicy().hasHeightForWidth() ) );
    Layout2->addWidget( cancelButton );

繼續編譯:

    錯誤提示:.ui/release-shared/camerabase.cpp:41: error: no matching function for call to ‘QSizePolicy:SizePolicy(QSizePolicy::SizeType, QSizePolicy::SizeType, int, int, bool)’
/root/yizhi/host/qtopia-free-2.2.0/qt2/include/qsizepolicy.h:93: note: candidates are: QSizePolicy:SizePolicy(int)

   解決辦法: 

     編輯  qtopia-free-2.2.0/qtopia/src/applications/camera/.ui/release-shared/camerabase.cpp 文件的第41行

videocaptureview->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 0, videocaptureview->sizePolicy().hasHeightForWidth() ) );

修改爲:

videocaptureview->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, videocaptureview->sizePolicy().hasHeightForWidth() ) );




下面將網上搜集的另外一點資料貼上:

1. Could not find wxWidgets library. 

Solution: $sudo apt-get install libwxgtk2.8-0 libwxgtk2.8-dev wx2.8-headers wx-common 

2. Need libsmbclient.h for compiling on Unix. 

Solution: $sudo apt-get install libsmbclient-dev 

3. Need cups.h for compiling on Unix. 

Solution: $sudo apt-get install libcupsys2-dev 

4. error: Need opensc/opensc.h. 

Solution: $sudo apt-get install libopensc2-dev 

5. exec: g++: not found. 

Solution: $sudo apt-get install build-essential 

6. error: X11/Xlib.h: no such file or directory. 

Solution: $sudo apt-get install libx11-dev 

7. error: X11/Xmu/WinUtil.h: no such file or directory. 

Solution: $sudo apt-get install libxmu-dev 

8. error: jpeglib.h: no such file or directory. 

Solution: $sudo apt-get install libjpeg-dev 

9. error: png.h: no such file or directory. 

Solution: $sudo apt-get install libpng-dev

   大體上能夠遇到的錯誤差不多就這幾種類型,關鍵是哪裏出錯去哪裏找,然後進入那個路徑,修改相應的錯誤,希望類似我這樣的初學者朋友戒浮忌躁,相信大家都會成功的。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章