久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

openWrt軟件開(kāi)發(fā)教程1(交叉編譯和ipk包生成)

 心不留意外塵 2016-07-30

http://blog.csdn.net/woods2001/article/details/8137755

2012

一,、交叉編譯

1.      建立交叉編譯環(huán)境

在使用buildroot對(duì)openwrt進(jìn)行編譯之后,在buildroot目錄下會(huì)有一個(gè)名叫staging_dir的目錄,針對(duì)當(dāng)前平臺(tái)的toolchain都在這個(gè)目錄下,。

1.1增加toolchain的目錄到PATH目錄中

Vim ~/.bash_profile

添加代碼:

# add openWrt cross-compile path

PATH=$PATH:/home/jason/openWrt/trunk/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/bin/

1.2   增加staging_dir的目錄到toolchain PATH

Vim ~/.bash_profile

添加代碼:

STAGING_DIR=/home/jason/openWrt/trunk/staging_dir/

exportSTAGING_DIR

1.3 保存退出

2.      編譯

2.1 configure

 ./configure--target=i486-openwrt-linux-uclibc

2.2 make

make CC=i486-openwrt-linux-uclibc-gcc LD=i486-openwrt-linux-uclibc-ld

二,、編譯ipk包

1.      編譯SDK

在buildroot目錄下make menuconfig,然后選中SDK進(jìn)行編譯


選中后,,進(jìn)行make編譯,。

編譯完成后,對(duì)應(yīng)生成的SDK會(huì)出現(xiàn)類(lèi)似這樣的目錄:“openWrt/trunk/bin/x86”,,進(jìn)入SDK后,,打印當(dāng)前工作路徑如下:

“/openWrt/trunk/bin/x86/OpenWrt-SDK-x86-for-redhat-x86_64-gcc-4.6-linaro_uClibc-0.9.33.2”

2.      創(chuàng)建工程

在sdk的package目錄下創(chuàng)建我們的工程“helloworld”:

新建目錄中包含src目錄,這個(gè)目錄就是我們的源代碼所在地,,另外一個(gè)非常重要的文件Makefile,,這個(gè)Makefile的組成與GNU的有所不同,有點(diǎn)類(lèi)似于制作rpm包時(shí)的spec文件,。到后面會(huì)有更詳細(xì)的介紹,。以下是具體文件的位置:


其中helloworld.c的內(nèi)容如下:


Src目錄下的Makefile文件內(nèi)容如下:

最后是helloworld目錄下的Makefile的內(nèi)容:

##############################################

# OpenWrtMakefile for helloworld program

#

#

# Most ofthe variables used here are defined in

# theinclude directives below. We just need to

# specifya basic description of the package,

# whereto build our program, where to find

# thesource files, and where to install the

#compiled program on the router.

#

# Be verycareful of spacing in this file.

# Indentsshould be tabs, not spaces, and

# thereshould be no trailing whitespace in

# linesthat are not commented.

#

##############################################

 

include$(TOPDIR)/rules.mk

 

# Nameand release number of this package

PKG_NAME:=helloworld

PKG_RELEASE:=1

 

 

# Thisspecifies the directory where we're going to build the program.

# Theroot build directory, $(BUILD_DIR), is by default the build_mipsel

#directory in your OpenWrt SDK directory

PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME)

 

 

include$(INCLUDE_DIR)/package.mk

 

 

 

# Specifypackage information for this program.

# Thevariables defined here should be self explanatory.

# If youare running Kamikaze, delete the DESCRIPTION

#variable below and uncomment the Kamikaze define

# directivefor the description below

definePackage/helloworld

SECTION:=utils

CATEGORY:=Utilities

TITLE:=Helloworld-- prints a snarky message

endef

 

 

 

# Specifywhat needs to be done to prepare for building the package.

# In ourcase, we need to copy the source files to the build directory.

# This isNOT the default.  The default uses thePKG_SOURCE_URL and the

#PKG_SOURCE which is not defined here to download the source from the web.

# Inorder to just build a simple program that we have just written, it is

# mucheasier to do it this way.

defineBuild/Prepare

mkdir -p $(PKG_BUILD_DIR)

$(CP) ./src/* $(PKG_BUILD_DIR)/

endef

 

 

# We donot need to define Build/Configure or Build/Compile directives

# Thedefaults are appropriate for compiling a simple program such as this one

 

 

# Specifywhere and how to install the program. Since we only have one file,

# thehelloworld executable, install it by copying it to the /bin directory on

# therouter. The $(1) variable represents the root directory on the router running

#OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install

#directory if it does not already exist. Likewise $(INSTALL_BIN) contains the

# commandto copy the binary file from its current location (in our case the build

#directory) to the install directory.

definePackage/helloworld/install

$(INSTALL_DIR) $(1)/bin

$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld$(1)/bin/

endef

 

 

# Thisline executes the necessary commands to compile our program.

# Theabove define directives specify all the information needed, but this

# linecalls BuildPackage which in turn actually uses this information to

# build apackage.

$(eval $(call BuildPackage,helloworld))

這個(gè)Makefile的語(yǔ)法規(guī)則還是參考官網(wǎng)吧:

http://wiki./doc/devel/packages

3.      編譯

將當(dāng)前目錄返回到SDK:

執(zhí)行make進(jìn)行編譯。如果一切順利,,最后的結(jié)果會(huì)保存在SDK/bin/x86/packages目錄下,,名稱(chēng)為helloword_1_x86.ipk。

4.      安裝最新編譯的包

通過(guò)scp將該包拷貝到目的機(jī)器上,,通過(guò)opkg包管理工具進(jìn)行安裝:

Opkg install helloworld_1_x86.ipk

一切順利,,包安裝成功,在當(dāng)前路徑下執(zhí)行helloworld查看程序執(zhí)行結(jié)果,。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn),。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多