用kdevelop进行交叉编译的方法

本文详细介绍了如何在kdevelop IDE中使用autotool、QMAKE和内核模块模板进行交叉编译,以提高嵌入式Linux开发的工作效率。
 用kdevelop进行交叉编译的方法。

首先提一下,我这篇文章,对于那些喜欢使用繁琐开发工具的达人们可以无视。

嵌入式的linux开发中,要建立的项目通常是三种,一是C或C++的工程。二是QT/E的工程,三是内核驱动

模块工程。管理三种工程,网上流传的方法大多是用autotool或qmake工具生成MAKEFILE,这两种工具使

用极其繁琐,尤其是autotool工具集,还是一“集”,其中,还要手工修改一些文件,其繁琐让人望而却

步。而内核模块的MAKEFILE则更是要手工编辑才行了,在实际工作中,用上述进行工程管理,频频出错,

严重影响工作效率。而linux的许多发行版中都已集成了kdevelop这个IDE,其可以对工程进行很好的管理

,而且它的编辑器又自带有代码缩进,代码补全等功能,十分好用。但是许多嵌入式工程师因为不知如何

使用kdevelop进行嵌入式开发所需的交叉编译,而放弃了它,实在可惜。
我在实际工作中,也先是使用了上述的方法,苦不堪言,而后才模出了在kdevelop3中进行交叉编译的方

法,工作效率明显提升。

我用的是Fedroa6的linux发行版,其自带kdevelop3和QT3的开发环境。下面的讲述都是在这个系统中实际

可行的。在其它系统中应该也是这样的。

我们用来开发ARM嵌入式系统时,常用到三种工程模板,第一种是C的简单的hello模板,C++的简单的

hello工程模板。两个模板都是kdevelop调用autotool工具集进行工程管理的。关于这个工具集,网上有

很多资料,就不多说了。第二种是QMAKE工程模板,它是调用QT的QMAKE工具来进行工程管理的。第三种,

就是linux内核模块工程模板,它由kdevelop自身来管理。下面,我就具体讲述一下如何在这种工程模板

中进行交叉编译。

第一种:kdevelop调用autotool工具集进行工程管理,它要进行交叉编译的设置是最简单的。只需在

kdevelop的工程->工程选项的对话框中打开配置选项栏作如下设置,在常规栏中,在“配置参数”中添加

一项“--host=arm-linux”,在CPPFLAGS中,加入“-I/usr/local/arm/3.4.1/arm-linux/include”(这

是我用的交叉编译器,你要设成你的,以下同),在LDFLAGS栏中,输入“-L/usr/local/arm/3.4.1/arm

-linux/lib”,在C栏中,CC中加入“/usr/local/arm/3.4.1/bin/arm-linux-gcc”,在CPP栏中,CXX中

加入“/usr/local/arm/3.4.1/bin/arm-linux-g++”。好了,选择构建->构建工程,交叉编译成功。这种

模板的设置是最简单的,设置后不用做任何处理,即可编译成功。(这是最简单的,却是我最后才摸出来

的,费了很多时间。主要是卡在配置参数中没有加入host=arm-linux,查了很多资料,才解决问题。)

第二种:kdevelop是调用QMAKE进行工程管理的。设置到是容易的。就是在工程选项的MAKE选项中,添加

四个环境变量。分别是QMAKESPEC,值为“/opt/qt-3.3.4-target/mkspecs/qws/linux-arm-g++”,QTDIR

,值为“/opt/qt-3.3.4-target”,QTINC,值为“/opt/qt-3.3.4-target/include”,QTLIB,值为

“/opt/qt-3.3.4-target/include”,其中/opt/qt-3.3.4-target,是我的交叉编译的QT/E库所在目录。

好了,设置完了,但如果你之前曾经对工程编译过(在开发嵌入式QTE时,这是常有的情况,主要是为了

测试一下界面的正确性),你这时再构建工程,就会报错,你要选择清理工程,还要删除工程所在目录下

所有的makefile文件,然后再构建工程就会成功。

第三种:kdevelop是自身在管理此工程的。没有什么可以设置的地方,要想它交叉编译,只有直接修改

makefile文件了。打开makefile文件,将其中的KDIR = /lib/modules/$(CURRENT)/build更改为KDIR =

/root/utu-linux_V1.5.3 (这是我的内核树所在目录。也就是交叉编译在开发板上使用的linux的那个目

录),保存。好了,选择“构建工程”,交叉编译成功。如果报错,则先选择“清理工程”即可。签于

kdevelop管理此项工程时不是很理想,比如,无法进行多文件的驱动编译。建议用网上提供的makefile模

板修改后直接替换原来的makefile。我把模板附在下面。

ifeq ($(KERNELRELEASE),)
KERNELDIR ?= /root/utu-linux_V1.5.3

PWD := $(shell pwd)
modules:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
    rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
PHONY: modules modules_install clean
else
    obj-m := xray.o
    xray-objs :=xray-driver.o hwdriver.o
endif

好了,到此,你基本就可以完全在kdevelop下进行嵌入式的开发和交叉编译了,怎么样,是不是觉得工作

效率大大提高了呢。

 

原文:http://blog.csdn.net/imho888/article/details/3450346

The KDevelop Programming Handbook1. Introduction1.1. What you should know already1.2. About this Handbook1.3. Additional Information2. The KDE and Qt Libraries2.1. The Qt GUI Toolkit2.1.1. The first Qt Application2.1.2. The Reference Documentation for Qt 2.1.3. Interpretation of the Sample2.1.4. User Interaction2.1.5. Object Interaction by Signals and Slots2.2. What KDE provides2.2.1. The KDE 1.1.x libraries2.2.2. Example KDE Application3. Creating new Applications3.1. Invoking KAppWizard and Project Generation3.1.1. Starting KAppWizard and the First Page3.1.2. The Generate Settings Page3.1.3. The Header and Source Templates3.1.4. Creating the Project3.2. The First Build3.3. The Source Skeleton3.3.1. The main() Function3.3.2. User Application Start3.3.3. Invocation by Session Management3.4. Additional Contents of KDevelop Projects4. Application View Design4.1. Using Library Views4.1.1. Qt Views4.1.2. KDE Views4.2. Creating your own Views5. Configuring Menubars and Toolbars5.1. How does it work ?5.2. Adding a new menu5.3. Integrating Toolbar buttons5.4. Configuring Statusbars5.5. Keyboard Accelerator Configuration6. The Dialogeditor: Where your Dialogs are Build6.1. What the Dialogeditor provides6.2. Qt and KDE Widgets6.3. Properties of Qt supported Widgets6.3.1. QWidget Properties6.3.2. QButton inherited widgets6.3.3. QComboBox Properties6.3.4. QFrame inherited widgets6.3.5. QLineEdit Properties6.3.6. QScrollBar Properties6.3.7. QSlider Properties6.4. Properties of KDE supported Widgets6.4.1. KColorButton6.4.2. KKeyButton6.4.3. KCombo6.4.4. KDatePicker6.4.5. KLedLamp6.4.6. KProgress6.4.7. KSeparator6.4.8. KDateTable6.4.9. KTreeList6.4.10. KRestrictedLine6.4.11. KLed6.5. Constructing a new Dialog6.6. Setting Widget Properties6.7. Integrating the Dialog6.7.1. QWidget inherited6.7.2. QDialog inherited7. Printing Support7.1. The Qt Print Dialog7.2. The QPainter Class8. Help Functions8.1. Tool-Tips8.2. Adding Quick-help8.3. Extending the Statusbar Help8.4. The "What's This...?" Button9. Extending the Documentation with SGML 9.1. Why SGML ?9.2. What the Documentation already contains9.3. Writing SGML Documentation9.3.1. The DTD Declaration9.3.2. Titlepages9.3.3. Indices9.3.4. The Document Contents9.4. How to call Help in Dialogs10. Class Documentation with KDoc 10.1. How to use KDevelop's Documentation features10.2. Adding Class and Member Documentation10.3. Special Tags11. Internationalization11.1. What is i18n ?11.2. How KDE supports Internationalization11.3. Adding a Language to your Project11.4. Translation Team Contacts12. Finding Errors12.1. Debugging Macros provided by Qt 12.2. KDE Macros13. The KDE File System Standard13.1. Introduction13.2. Directory Layout13.3. What does this mean to application developers?13.4. Application Documentation13.5. What does this mean to library developers?14. File System Usage for KDevelop Projects14.1. Accessing Files during Runtime14.2. KApplication Methods14.3. KIconLoader Methods14.4. Setting File Installation Properties14.5. Organizing Project Data14.6. The kdelnk File15. Programming Guidelines15.1. General Rules15.2. Operating System Dependencies16. Licensing16.1. The GPL License16.2. KDE and Qt Licensing Issues16.2.1. Non-commercial Development16.2.2. Commercial Development16.3. Your Product License17. References18. CopyrightA. Additional InformationA.1. Example Makefile.am for a Shared Library
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值