交叉編譯libxml2
Ⅰ 如何在32位ubuntu11.10 下編譯android 4.0.1源碼和goldfish內核
一準備工作
1安裝javasdk6
(1)從jdk官方網站http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u29-download-513648.html下載jdk-6u29-linux-i586.bin文件。
(2)執行jdk安裝文件
[html] view plain
$chmod a+x jdk-6u29-linux-i586.bin
$jdk-6u29-linux-i586.bin
(3)配置jdk環境變數
[html] view plain
$sudo vim /etc/profile
[html] view plain
#JAVAEVIRENMENT
exportJAVA_HOME=/usr/lib/java/jdk1.6.0_29
exportJRE_HOME=$JAVA_HOME/jre
exportCLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
exportPATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
保存後退出編輯,並重啟系統。
2安裝依賴包
[html] view plain
$sudo apt-get install git-core gnupg flex bison gperf build-essential\
zipcurlzlib1g-devlibc6-devlib32ncurses5-devia32-libs\
x11proto-core-devlibx11-devlib32readline5-devlib32z-dev\
libgl1-mesa-devg++-multilibmingw32tofrodospython-markdown\
libxml2-utils
3用repo工具下載源碼
(1)初始化repo
[html] view plain
$cd ~
$mkdir bin
$curlhttps://dl-ssl.google.com/dl/googlesource/git-repo/repo>~/bin/repo
$chmod a+x ~/bin/repo
$exportPATH=$PATH:~/bin(導出環境變數)
(2)下載android最新源碼
[html] view plain
$mkdir android
$cd android
$ repo init -u https://android.googlesource.com/platform/manifest -bandroid-4.0.1_r1
...(輸入用戶名和郵箱名)
$repo sync -j5
...(此處用5個線程開始下載源碼,下載過程及其漫長,需要耐心等待)
二 編譯源碼
1開始編譯
[html] view plain
$source build/envsetup.sh
includingdevice/samsung/maguro/vendorsetup.sh
includingdevice/samsung/tuna/vendorsetup.sh
includingdevice/ti/panda/vendorsetup.sh
includingsdk/bash_completion/adb.bash
$make-j4(此處用4個線程編譯)
編譯完成後,會看到類似的輸出:
[html] view plain
Targetramdisk:out/target/proct/generic/ramdisk.img
Targetuserdatafsimage:out/target/proct/generic/userdata.img
Installedfilelist:out/target/proct/generic/installed-files.txt
2編譯遇到的問題
編譯錯誤:
[html] view plain
<命令行>:0:0:錯誤:「_FORTIFY_SOURCE」重定義[-Werror]
<built-in>:0:0:附註: 這是先前定義的位置
cc1plus:所有的警告都被當作是錯誤
make:*** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o]錯誤 1
原因:
因機器上的gcc版本過高,需替換成4.4.6重新進行編譯。
解決方法:
1)安裝4.4版本的gcc和g++
[html] view plain
$ sudo apt-get install gcc-4.4
$ sudo apt-get install g++-4.4
2)設置gcc版本,使gcc鏈接到gcc-4.4
[html] view plain
$ ls -l /usr/bin/gcc*
lrwxrwxrwx 1 root root 7 2011-11-01 23:56 /usr/bin/gcc -> gcc-4.6
-rwxr-xr-x 1 root root 224544 2011-10-06 05:47 /usr/bin/gcc-4.4
-rwxr-xr-x 1 root root 302104 2011-09-17 05:43 /usr/bin/gcc-4.6
$ cd /usr/bin
$ sudo mv gcc gcc.bak
$ sudo ln -s gcc-4.4 gcc
3)設置g++版本,使g++鏈接到g++-4.4
[html] view plain
$ sudo mv g++ g++.bak
$ sudo ln -s g++-4.4 g++
4)設置完畢後,重新進行編譯即可
3從模擬器啟動編譯後的鏡像文件
1)設置環境變數:
[html] view plain
export PATH=~/android/out/host/linux-x86/bin:$PATH
export ANDROID_PRODUCT_OUT=~/android/out/target/proct/generic
其中linux-x86/bin存放模擬器emulator工具,proct/generic存在編譯後的鏡像文件。
2)啟動模擬器
[html] view plain
$emulator
emulator:WARNING: system partition size adjusted to match image file (162 MB >66 MB)
啟動後的截圖:
三 編譯androidgoldfish內核
1)進入android4.0.1源碼目錄,下載goldfish內核源碼
[html] view plain
$ mkdir kernel
$ cd kernel
$ git clone http://android.googlesource.com/kernel/goldfish.git
$ cd goldfish
$ git branch -a
* (no branch)
master
remotes/origin/HEAD -> origin/master
remotes/origin/android-goldfish-2.6.29
remotes/origin/master
$ git checkout remotes/origin/android-goldfish-2.6.29
2)修改Makefile
[html] view plain
goldfish$ gedit Makefile
修改
[html] view plain
ARCH ?=$(SUBARCH)
CROSS_COMPILE ?=
為
[html] view plain
ARCH ?=arm
CROSS_COMPILE ?=arm-eabi-
3)導出交叉編譯器目錄為環境變數
$ export PATH=$PATH:~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
4)編譯內核
[html] view plain
goldfish$ make goldfish_armv7_defconfig
goldfish$ make
編譯完成後,可看到類似如下的輸出:
[html] view plain
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
5)從模擬器中啟動內核鏡像
[html] view plain
$emulator -kernel ~/android/kernel/goldfish/arch/arm/boot/zImage &
啟動模擬器後,可從Settings->System->AboutPhone中查看內核版本信息。
Ⅱ 編譯libxml2.so而且編譯出來的.so文件都是intel80386的,怎麼改成ARM的
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt/arm-libxml
make
make install
1要有arm-linux-gcc編譯器
2make install後會在prefix指定的地方放置include bin lib man share mans等目錄
上面過程叫做交叉編譯cross-compile
Ⅲ 如何使用libxml2庫
庫的路徑和頭文件我都設置進去了,怎麼編譯的時候老是報如下錯誤:
1>libxml2.lib(nanohttp.obj) : error LNK2019: 無法解析的外部符號 __imp__WSAStartup@8,該符號在函數 _xmlNanoHTTPInit 中被引用
1>libxml2.lib(nanoftp.obj) : error LNK2001: 無法解析的外部符號 __imp__WSAStartup@8
1>libxml2.lib(nanohttp.obj) : error LNK2019: 無法解析的外部符號 __imp__WSACleanup@0,該符號在函數 _xmlNanoHTTPCleanup 中被引用
1>libxml2.lib(nanoftp.obj) : error LNK2001: 無法解析的外部符號 __imp__WSACleanup@0
1>libxml2.lib(nanohttp.obj) : error LNK2019: 無法解析的外部符號 __imp__select@20,該符號在函數 _xmlNanoHTTPRecv 中被引用
1>libxml2.lib(nanoftp.obj) : error LNK2001: 無法解析的外部符號 __imp__select@20
1>libxml2.lib(nanohttp.obj) : error LNK2019: 無法解析的外部符號 __imp__recv@16,該符號在函數 _xmlNanoHTTPRecv 中被引用
1>libxml2.lib(nanoftp.obj) : error LNK2001: 無法解析的外部符號 __imp__recv@16
1>libxml2.lib(nanohttp.obj) : error LNK2019: 無法解析的外部符號 __imp__WSAGetLastError@0,該符號在函數 _socket_errno 中被引用
1>libxml2.lib(nanohttp.obj) : error LNK2019: 無法解析的外部符號 __imp__closesocket@4,該符號在函數 _xmlNanoHTTPFreeCtxt 中被引用
1>libxml2.lib(nanoftp.obj) : error LNK2001: 無法解析的外部符號 __imp__closesocket@4
1>libxml2.lib(nanohttp.obj) : error LNK2019: 無法解析的外部符號 __imp__send@16,該符號在函數 _xmlNanoHTTPSend 中被引用
1>libxml2.lib(nanoftp.obj) : error LNK2001: 無法解析的外部符號 __imp__send@16
1>libxml2.lib(nanohttp.obj) : error LNK2019: 無法解析的外部符號 __imp__htons@4,該符號在函數 _xmlNanoHTTPConnectHost 中被引用
1>libxml2.lib(nanoftp.obj) : error LNK2001: 無法解析的外部符號 __imp__htons@4
1>libxml2.lib(nanohttp.obj) : error LNK2019: 無法解析的外部符號 __imp__WSASetLastError@4,該符號在函數 _WspiapiGetAddrInfo@16 中被引用
libxml2使用了網路庫,所以鏈接加上 ws2_32.lib 這個庫就可以了
Ⅳ vs怎麼編譯libxml2源碼
編譯Android 源代碼,Android官方推薦64位的ubuntu系統,最好是10.04的,對於10.10、11.10、12.04版本的ubuntu系統也是可以,但是小編一直習慣使用10.04的,所以幾年來一直沿用至今
請不要使用32位的Ubuntu系統,更不要使用10.04以下的ubuntu系統,不然編譯會出現很多都問題,會浪費更多的時間,有的比較難解決,對於新人來說,還不如重新安裝一個64位的ubuntu系統
下面小編來說說怎麼樣查看當前安裝好的ubuntu系統是多少位的
按照下圖所示的方法打開終端,然後輸入命令並執行 uname -ar,在最後輸出的信息中如果有amd64或者 x86_64 字樣,那麼就說明是64位的系統了,否則就是32位的系統了
Ⅳ libxml2 和libxml的區別
一般這種命名規則: lib, lib-dev,前一個是程序運行時需要的庫,後一個是編譯源碼時需要的庫,只不過一個是運行庫,一個是開發庫。供參考。
Ⅵ 怎麼用libxml2 默認解析器解析HTML文件
C程序里可以利用libxml2庫去解析xml文檔。利用libxml2可以很輕松的解析,生成xml文件。
這里演示一個小例子,包含了遍歷節點,獲取節點屬性與值,以及獲取CDATA裡面的內容。
測驗的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<root name="test">
<content>
<pro id="moonApple"><![CDATA[<say>i still have lots to work on</say>]]></pro>
<details>
<detail name="dancing">like it</detail>
<detail name="singing">poor , just listen</detail>
<detail name="laugh"/>
<detail name="eating"><![CDATA[<food>candy</food>]]></detail>
</details>
</content>
</root>
test.c文件:
#include<stdio.h>
#include<string.h>
#include<libxml/parser.h>
#include<libxml/tree.h>
int parse_xml_file(char *buf,int len){
xmlDocPtr doc;
xmlNodePtr root,node,detail;
xmlChar *name,*value;
doc=xmlParseMemory(buf,len); //parse xml in memory
if(doc==NULL){
printf("doc == null\n");
return -1;
}
root=xmlDocGetRootElement(doc);
for(node=root->children;node;node=node->next){
if(xmlStrcasecmp(node->name,BAD_CAST"content")==0)
break;
}
if(node==NULL){
printf("no node = content\n");
return -1;
}
for(node=node->children;node;node=node->next){
if(xmlStrcasecmp(node->name,BAD_CAST"pro")==0){ //get pro node
name=xmlGetProp(node,BAD_CAST"id");
value=xmlNodeGetContent(node);
printf("this is %s:\n%s\n",(char*)name,(char*)value); //get value, CDATA is not parse and don't take into value
xmlFree(name);
xmlFree(value);
}else if(xmlStrcasecmp(node->name,BAD_CAST"details")==0){ //get details node
for(detail=node->children;detail;detail=detail->next){ //traverse detail node
if(xmlStrcasecmp(detail->name,BAD_CAST"detail")==0){
name=xmlGetProp(detail,BAD_CAST"name");
value=xmlNodeGetContent(detail);
if(strlen((char*)value)!=0){
printf("%s : %s\n",(char*)name,(char*)value);
}else{
printf("%s has no value\n",(char*)name);
}
xmlFree(name);
xmlFree(value);
}
}
}
}
xmlFreeDoc(doc);
return 0;
}
int main(void){
char *content;
unsigned long filesize;
FILE *file;
if((file=fopen("testxml","r"))==NULL){
perror("openf file error");
}
fseek(file,0,SEEK_END);
filesize=ftell(file);
rewind(file);
content=(char *)malloc(filesize+1);
memset(content,0,filesize+1);
fread(content,1,filesize,file);
fclose(file);
printf("content:\n%s\n",content);
if(parse_xml_file(content,filesize)<0){
perror("parse xml failed");
}
return 0;
}
輸出結果:
this is moonApple:
<say>i still have lots to work on</say>
dancing : like it
singing : poor , just listen
laugh has no value
eating : <food>candy</food>
這里主要關注XML文件裡面的CDATA裡面的內容
Ⅶ 新手請教~~~如何交叉編譯libxml2,如何移植sqlite3到arm開發板!!!
先配置,然後使用交叉編譯器編譯,然後install到一個文件夾下,把install的內容拷貝到開發板文件系統的/usr或者/usr/local目錄下!
Ⅷ 編譯可以通過,但是下載到開發板之後運行,提示找不到第三方庫文件(libxml2.so.2),求解,急急急!!!
去找到編譯器下面的這個庫然後放到開發板的lib目錄下面
Ⅸ 如何在工程中調用libxml2-.2.7.8庫函數
不同的編譯器,應該不是主要的影響因素吧。最主要應該看的是函數庫的文檔。當然,MS-DOS 沒有可以自由使用的函數庫,Turbo C 發行版本中附帶了一套部分與 ANSI C 兼容的函數庫;但由於 Turbo C 裡面的很多庫函數限制了用戶只能在 MS-DOS 下使用所寫的程序,所以初學者使用 Turbo C 以後時常會有一種 「礙手礙腳」 的感覺:怎麼這個函數在 Unix 下不支持呢,怎麼那個函數不能拿到 Windows 那裡用?Turbo C 也幾乎沒有可移植性。鑒於以上幾點,我本人並不推薦使用 Turbo C,至少不宜過多地依賴 Turbo C 里系統平台相關的庫函數。