Ubuntu 14.04 LTS 64位 英文版本下libxml2-2.9.2.tar.gz的交叉编译

http://www.aichengxu.com/diannao/40322.htm
Ubuntu下libxml2的交叉编译


2014-12-26 13:10 本站整理 浏览(587)
Ubuntu下libxml2的交叉编译,有需要的朋友可以参考下。


环境为Ubuntu 14.04 LTS 64位 英文版本。
使用的交叉编译工具是arm-linux-gcc-4.3.2.tgz。




一、准备libxml2库 
libxml2是一个跨平台的xml文件操作库。
项目地址:http://www.xmlsoft.org/
我使用的是最新版本libxml2-2.9.2.tar.gz




二、安装 
我在在官网提供的网址https://git.gnome.org/browse/libxml2/上下载了几个版本的.tar.gz在Ubuntu下解压以后都没有看到configure文件,然后在ftp://xmlsoft.org/libxml2/下载的版本里却有configure文件……折腾一早上,简直坑爹,希望朋友们少走弯路……


在解压文件夹下


rootroot@rootroot-virtual-machine:~/wyb$ cd libxml2-2.9.2/
rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ ./configure --prefix=/home/rootroot/wyb/libxml2-2.9.2/install CC=arm-linux-gcc LD=arm-linux-ld --enable-shared --enable-static --host=arm-linux --with-python=/home/rootroot/wyb/libxml2-2.9.2/python
rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ make
rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ make install


注意修改自己的交叉编译工具。如果不指定python路径(--with-python=/home/rootroot/wyb/libxml2-2.9.2/python),make之后会提示:
rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ make


make[4]: Entering directory `/home/rootroot/wyb/libxml2-2.9.2/python'
  CC       libxml.lo
cc1: warning: include location "/usr/include/python2.7" is unsafe for cross-compilation
In file included from /usr/include/python2.7/Python.h:8,
                 from libxml.c:14:
/usr/include/python2.7/pyconfig.h:15:52: error: arm-linux-gnueabi/python2.7/pyconfig.h: No such file or directory
In file included from /usr/include/python2.7/Python.h:77,
                 from libxml.c:14:
/usr/include/python2.7/pymath.h:18: warning: redundant redeclaration of 'copysign'
/usr/include/python2.7/pymath.h:26: warning: redundant redeclaration of 'hypot'
libxml.c: In function 'xmlPythonFileReadRaw':
libxml.c:297: error: expected '(' before numeric constant
libxml.c: In function 'xmlPythonFileRead':
libxml.c:362: error: expected '(' before numeric constant
make[4]: *** [libxml.lo] Error 1
make[4]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2/python'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2/python'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2/python'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2'
make: *** [all] Error 2
rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ 




参考资料:
http://blog.csdn.net/q1302182594/article/details/44975527
Linux中交叉编译libxml2




三、测试 
随便找一个测试程序:


// test.c
#include <stdio.h>
#include <libxml/parser.h>
#include <libxml/tree.h>


int main(int argc, char **argv)
{
xmlDocPtr doc = NULL;
xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;

doc = xmlNewDoc(BAD_CAST "1.0");
root_node = xmlNewNode(NULL, BAD_CAST "root");
xmlDocSetRootElement(doc, root_node);
xmlNewChild(root_node, NULL, BAD_CAST "node1",BAD_CAST "content of node1");
node=xmlNewChild(root_node, NULL, BAD_CAST "node3",BAD_CAST"node has attributes");
xmlNewProp(node, BAD_CAST "attribute", BAD_CAST "yes");
node = xmlNewNode(NULL, BAD_CAST "node4");
node1 = xmlNewText(BAD_CAST"other way to create content");
xmlAddChild(node, node1);
xmlAddChild(root_node, node);
xmlSaveFormatFileEnc(argc > 1 ? argv[1] : "-", doc, "UTF-8", 1);
xmlFreeDoc(doc);
xmlCleanupParser();
xmlMemoryDump();

return(0);
}




编译:
rootroot@rootroot-virtual-machine:~/wyb$ arm-linux-gcc -I /home/rootroot/wyb/libxml2-2.9.2/install/include/libxml2  -L /home/rootroot/wyb/libxml2-2.9.2/install/lib -lxml2 test.c -o test
rootroot@rootroot-virtual-machine:~/wyb$ file test
test: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped
rootroot@rootroot-virtual-machine:~/wyb$ 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ubuntulibxml2交叉编译 2014-12-26 13:10 本站整理 浏览(587) Ubuntulibxml2交叉编译,有需要的朋友可以参考下。 环境为Ubuntu 14.04 LTS 64位 英文版本。 使用的交叉编译工具是arm-linux-gcc-4.3.2.tgz。 一、准备libxml2libxml2是一个跨平台的xml文件操作库。 项目地址:http://www.xmlsoft.org/ 我使用的是最新版本libxml2-2.9.2.tar.gz 二、安装 我在在官网提供的网址https://git.gnome.org/browse/libxml2/上下载了几个版本的.tar.gzUbuntu下解压以后都没有看到configure文件,然后在ftp://xmlsoft.org/libxml2/下载的版本里却有configure文件……折腾一早上,简直坑爹,希望朋友们少走弯路…… 在解压文件夹下 rootroot@rootroot-virtual-machine:~/wyb$ cd libxml2-2.9.2/ rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ ./configure --prefix=/home/rootroot/wyb/libxml2-2.9.2/install CC=arm-linux-gcc LD=arm-linux-ld --enable-shared --enable-static --host=arm-linux --with-python=/home/rootroot/wyb/libxml2-2.9.2/python rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ make rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ make install 注意修改自己的交叉编译工具。如果不指定python路径(--with-python=/home/rootroot/wyb/libxml2-2.9.2/python),make之后会提示: rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ make make[4]: Entering directory `/home/rootroot/wyb/libxml2-2.9.2/python' CC libxml.lo cc1: warning: include location "/usr/include/python2.7" is unsafe for cross-compilation In file included from /usr/include/python2.7/Python.h:8, from libxml.c:14: /usr/include/python2.7/pyconfig.h:15:52: error: arm-linux-gnueabi/python2.7/pyconfig.h: No such file or directory In file included from /usr/include/python2.7/Python.h:77, from libxml.c:14: /usr/include/python2.7/pymath.h:18: warning: redundant redeclaration of 'copysign' /usr/include/python2.7/pymath.h:26: warning: redundant redeclaration of 'hypot' libxml.c: In function 'xmlPythonFileReadRaw': libxml.c:297: error: expected '(' before numeric constant libxml.c: In function 'xmlPythonFileRead': libxml.c:362: error: expected '(' before numeric constant make[4]: *** [libxml.lo] Error 1 make[4]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2/python' make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2/python' make[2]: *** [all] Error 2 make[2]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2/python' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2' make: *** [all] Error 2 rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ 参考资料: http://blog.csdn.net/q1302182594/article/details/44975527 Linux中交叉编译libxml2 三、测试 随便找一个测试程序: // test.c #include #include #include int main(int argc, char **argv) { xmlDocPtr doc = NULL; xmlNodePtr root_node = NULL, node = NULL, node1 = NULL; doc = xmlNewDoc(BAD_CAST "1.0"); root_node = xmlNewNode(NULL, BAD_CAST "root"); xmlDocSetRootElement(doc, root_node); xmlNewChild(root_node, NULL, BAD_CAST "node1",BAD_CAST "content of node1"); node=xmlNewChild(root_node, NULL, BAD_CAST "node3",BAD_CAST"node has attributes"); xmlNewProp(node, BAD_CAST "attribute", BAD_CAST "yes"); node = xmlNewNode(NULL, BAD_CAST "node4"); node1 = xmlNewText(BAD_CAST"other way to create content"); xmlAddChild(node, node1); xmlAddChild(root_node, node); xmlSaveFormatFileEnc(argc > 1 ? argv[1] : "-", doc, "UTF-8", 1); xmlFreeDoc(doc); xmlCleanupParser(); xmlMemoryDump(); return(0); } 编译: rootroot@rootroot-virtual-machine:~/wyb$ arm-linux-gcc -I /home/rootroot/wyb/libxml2-2.9.2/install/include/libxml2 -L /home/rootroot/wyb/libxml2-2.9.2/install/lib -lxml2 test.c -o test rootroot@rootroot-virtual-machine:~/wyb$ file test test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped rootroot@rootroot-virtual-machine:~/wyb$

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值