交叉编译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 里系统平台相关的库函数。