【轉載】Qt Creator + MinGW 在windows 下的調試
Qt的安裝配置請參考本部落格本分類下的其他相關文章,本文主要整理在調試時候遇到的問題和解決方案供遇到同樣問題的同學參考。由於我之前也沒有任何Qt的開發基礎,做的也是硬體方面設計,所以這方面基礎還是比較薄弱,這兒主要記錄摸索過程中的一點心得體會。
Qt的安裝和初步配置請參見:Qt Creator的配置和開發初步測試
本文的軟體環境:
Win7 32bit
Qt 4.8.4
Qt Creator 2.6.1
MinGW 4.4
摸索了一段時間的Qt和OpenCV,3個平台都有涉及,最大的問題還在於資源過於分散,版本之間很多地方還是有差異的,對於我這樣的初學者還是有點麻煩的。
今天使用到Qt的調試這塊,遇到了點小問題,這裡簡單記錄。
在進行調試的時候Qt Creator提示調試器未設定,在之前的的配置中也沒有留意,於是重新來看看,我用的是MinGW,於是通過自動檢測就得到了所示的設定。
程式檢測到了位於D:\mingw\bin\gdb.exe的調試器,本來覺得這樣就可以了,但是在調試的時候發現壓根沒法運行,提升(示)如下:
無奈,只能在找找法子,通過尋找發現,在之前的Qt Creator中,是以一個Qt SDK的整體來提供的,裡面就包括了MinGW和調試器,而且也無需配置,現在的新版本都是分散安裝的,所以就需要自己單獨再找找了。網上的一個說法是2.5以上的版本必須使用7.2 IIRC版以上的GDB,需要需要自己單獨下載,這裡我找到兩個。
http://qt-project.org/wiki/QtCreatorBuildGdb
內容粘貼如下:
Building GDB
For Windows
A msys Environment with MinGW is required to build the GDB on Windows.
If it is missing
download [sourceforge.net] and install it to your system.
Building
- Go to qt-creator/dist/gdb
- The directory has 3 Makefiles: linux, osx andmingw. Use the one that corresponds to your host os.
- In case you need additional targets, edit the line starting with ‘targets=’ in the Makefile.
- Run:
make -f Makefile.<linux|osx|mingw>
Shipping
- Extract qtcreator-gdb-<gdb version>-<host>.tar.gz
Testing
- To test GDB just run the executable and type:
python print 23
- When the GDB prints “23” everything works fine.
Downloads
- GDB 7.5 binaries
[origin.releases.qt-project.org]
- Compiled python for Windows[get.qt.nokia.com]
Categories:
- Tools
- QtCreator
- 這段文字想說明什麼內容看的不是很明白,而且我壓根沒找到qt-creator/dist/gdb 這個路徑存在,我下載了Downloads中的GDB 7.5 binaries,檔案名稱為qtcreator-gdb-7.4-MINGW32_NT-6.1-i686.tar.gz,直接用winRAR解壓,檔案夾內容如下:
重新設定Qt Creator將調試器定位到這個目錄中的gdb-686-pc-mingw32.exe如所示,再次調試,能夠進行調試。
另外一個http://builds.qt-project.org/job/gdb-windows/ 同樣能夠下載這個檔案。
Linux相關設定有對應的檔案,如下:http://builds.qt-project.org/view/GDB/job/gdb-unix/label=ubuntu32-builder-1004/
這裡並沒有測試。
文章轉自:http://emouse.cnblogs.com