在樹莓派上安裝了官方的raspbian系統。為了在能在上面開發程序,在系統上安裝了qt4 。參考鏈接http://qt-project.org/wiki/apt-get_Qt4_on_the_Raspberry_Pi
apt-get
Firstly I got the development tools needed by Qt Creator in the hope it would be less heavy for the Pi to download separately.
-
sudo apt -get install qt4 -dev -tools
Then I went for Qt Creator
-
sudo apt -get install Qtcreator
I also installed
-
sudo apt -get install gcc
-
sudo apt -get install xterm
-
sudo apt -get install git -core
-
sudo apt -get install subversion
this gives as a result Qt Creator 2.5 with Qt 4.8.1 32 bit
Problem : no toolchain.
We can only compile for remote embedded devices and this is not the case here, because we are on the Pi and not remotely accessing it.
I added a gcc toolchain
Options > build & run > tab tool chain > button add
Choose GCC
- Then set compiler path : /usr/bin/arm-linux-gnueabihf-gcc-4.6
- Debugger : /usr/bin/gdb
- Mkspec : default
Qt Creator seems to detect that we are going to deploy on a remote target.
To fix this :
- Go to menu help > about plugins
- Uncheck device support > remote linux
- Restart Qt Creator
- Go to tools > options TAB > build & run > Qt versions > add “/usr/bin/qmake-qt4”
It will then show up as a desktop project in the project wizard instead of embedded.
下載的raspbian系統比較新,里頭已經內置了GCC,跟着網站的步驟走,很容易就能完成QT4的安裝。注意sudo apt-get install Qtcreator中Qtcreator首字母要小寫,要不然樹莓派的服務器會找不到安裝程序提示錯誤。
以前在做linux QT開發中 喜歡直接在window上用UE進行編輯,然后ftp到虛擬機中。同樣可以用這種方式對樹莓派進行qt的開發。在我下的raspbian中沒有安裝ftp。
第一步 通過雲安裝,sudo apt-get install vsftpd。
第二步 對ftp進行配置,sudo vim /etc/vsftpd.conf。anonymous_enable=NO,local_enable=YES,write_enable=YES,local_umask=022。
第三步 重啟ftp服務 sudo service vsftpd restart
這樣就能在UE上編寫qt程序了。不過程序在樹莓派上直接編譯還是比較慢的,建議還是使用交叉編譯的方式。
PS:安裝qt需要比較大的空間,建議使用4G以上的SD卡,並且在raspi-config中Expand Filesystem使系統使用整張SD卡的大小,要不然只會分配2G多供系統使用。