当前位置: 技术问答>linux和unix
交叉编译libxml2出错
来源: 互联网 发布时间:2017-05-22
本文导语: 使用的libxml版本是 libxml2-2.7.8 交叉编译工具是mipsel-linux-gcc 3.4.2 配置如下:./configure --host=mipsel-linux --prefix=/finrod/mips_lib/test_xml/libxml --enable-static=yes --without-zlib 在make的时候,出现以下错误: Making all in . make[3...
使用的libxml版本是 libxml2-2.7.8
交叉编译工具是mipsel-linux-gcc 3.4.2
配置如下:./configure --host=mipsel-linux --prefix=/finrod/mips_lib/test_xml/libxml --enable-static=yes --without-zlib
在make的时候,出现以下错误:
说是没有mipsel-linux-gnu/python2.7/pyconfig.h这个文件
/usr/include/python2.7/pyconfig.h中这里的代码是
有哪位高手知道,这个文件夹和文件应该怎么弄出来?需要交叉编译python吗?
谢谢~
交叉编译工具是mipsel-linux-gcc 3.4.2
配置如下:./configure --host=mipsel-linux --prefix=/finrod/mips_lib/test_xml/libxml --enable-static=yes --without-zlib
在make的时候,出现以下错误:
Making all in .
make[3]: 正在进入目录 `/finrod/mips_lib/test_xml/libxml2-2.7.8/python'
/bin/sh ../libtool --tag=CC --mode=compile mipsel-linux-gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/include/python2.7 -I../include -I../include -I../python -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -MT libxml.lo -MD -MP -MF .deps/libxml.Tpo -c -o libxml.lo `test -f './libxml.c' || echo './'`./libxml.c
libtool: compile: mipsel-linux-gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/include/python2.7 -I../include -I../include -I../python -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -MT libxml.lo -MD -MP -MF .deps/libxml.Tpo -c ./libxml.c -fPIC -DPIC -o .libs/libxml.o
In file included from /usr/include/python2.7/Python.h:8,
from ./libxml.c:14:
/usr/include/python2.7/pyconfig.h:24:52: mipsel-linux-gnu/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'
In file included from /usr/include/python2.7/Python.h:110,
from ./libxml.c:14:
/usr/include/python2.7/pycapsule.h:31: warning: declaration of 'destructor' shadows a global declaration
/usr/include/python2.7/object.h:306: warning: shadowed declaration is here
/usr/include/python2.7/pycapsule.h:45: warning: declaration of 'destructor' shadows a global declaration
/usr/include/python2.7/object.h:306: warning: shadowed declaration is here
In file included from /usr/include/python2.7/Python.h:133,
from ./libxml.c:14:
/usr/include/python2.7/abstract.h:1387: warning: declaration of 'index' shadows a global declaration
/finrod/buildroot-gcc342/bin/../lib/gcc/mipsel-linux-uclibc/3.4.2/../../../../mipsel-linux-uclibc/sys-include/string.h:321: warning: shadowed declaration is here
/usr/include/python2.7/abstract.h:1389: warning: declaration of 'index' shadows a global declaration
/finrod/buildroot-gcc342/bin/../lib/gcc/mipsel-linux-uclibc/3.4.2/../../../../mipsel-linux-uclibc/sys-include/string.h:321: warning: shadowed declaration is here
./libxml.c:2678: warning: no previous prototype for 'libxml_xmlNodeRemoveNsDef'
./libxml.c: In function `libxml_serializeNode':
./libxml.c:2765: warning: unused variable `len'
./libxml.c: At top level:
./libxml.c:1775: warning: unused parameter 'severity'
./libxml.c:1748: warning: unused parameter 'severity'
make[3]: *** [libxml.lo] 错误 1
make[3]:正在离开目录 `/finrod/mips_lib/test_xml/libxml2-2.7.8/python'
make[2]: *** [all-recursive] 错误 1
make[2]:正在离开目录 `/finrod/mips_lib/test_xml/libxml2-2.7.8/python'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/finrod/mips_lib/test_xml/libxml2-2.7.8'
make: *** [all] 错误 2
说是没有mipsel-linux-gnu/python2.7/pyconfig.h这个文件
/usr/include/python2.7/pyconfig.h中这里的代码是
# if _MIPS_SIM == _ABIO32
# include
# elif _MIPS_SIM == _ABIN32
# include
# elif _MIPS_SIM == _ABI64
# include
# else
# error unknown multiarch location for pyconfig.h
# endif
有哪位高手知道,这个文件夹和文件应该怎么弄出来?需要交叉编译python吗?
谢谢~
|
自己解决了,由于不能还分给自己,只能另外用个号把解决方法贴出来。
在Makefile中有看到需要 -lpython2.7 所以肯定了需要交叉编译python
步骤如下
1. python的编译 使用文件 python.2.7
参考网址 http://www.linuxidc.com/Linux/2014-03/98457.htm
http://blog.csdn.net/shuxiao9058/article/details/7026205
(1) 由于在编译python的时候,需要先编译一个叫pgen的程序出来,用于生成语法解析器,所以我们要先生成一个pc版本的pgen
mkdir build.pc
cd build.pc
../configure
make Parser/pgen
(2) cd ../
echo ac_cv_file__dev_ptmx=no > config.site
echo ac_cv_file__dev_ptc=no >> config.site
export CONFIG_SITE=config.site
./configure CC=mipsel-linux-gcc CXX=mipsel-linux-g++ --host=mipsel-linux --build=i386-linux-gnu --disable-ipv6
(3) 修改makefile
OPT= -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
一行中,去掉-g,我们不要debug python,-O3改为-O2,空间紧张O2就可以了。
PGEN= Parser/pgen$(EXE)
一行的下面加上 PGEN_HOST= ../build.pc/Parser/pgen$(EXE)
表明我们在HOST上运行的pgen,在要使用PGEN的地方改为PGEN_HOST:
$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
改为:
$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
-$(PGEN_HOST) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
修改所有使用新生成的python的地方。
所有如 ./$(BUILDPYTHON) 的地方,都改为python
2. libxml的编译 使用文件 libxml2-2.7.8
首先要将第1步编译出来的python加入交叉编译器中,步骤如下
(1) 修改/usr/include/python2.7/pyconfig.h 第24行 改为 # include
(2) 将/usr/include/i386-linux-gnu目录下的python2.7文件夹拷贝到交叉编译器mipsel-linux-gcc默认的include文件夹中
/finrod/buildroot-gcc342/lib/gcc/mipsel-linux-uclibc/3.4.2/include/i386-linux-gnu
(3) 将编译好的libpython2.7.a拷贝到交叉编译器的lib文件中 /finrod/buildroot-gcc342/lib
libxml的编译
./autogen.sh
./configure --host=mipsel-linux --prefix=/finrod/mips_lib/test_xml/libxml --enable-static=yes CC=mipsel-linux-gcc CXX=mipsel-linux-g++ --without-zlib
make
make install
在Makefile中有看到需要 -lpython2.7 所以肯定了需要交叉编译python
步骤如下
1. python的编译 使用文件 python.2.7
参考网址 http://www.linuxidc.com/Linux/2014-03/98457.htm
http://blog.csdn.net/shuxiao9058/article/details/7026205
(1) 由于在编译python的时候,需要先编译一个叫pgen的程序出来,用于生成语法解析器,所以我们要先生成一个pc版本的pgen
mkdir build.pc
cd build.pc
../configure
make Parser/pgen
(2) cd ../
echo ac_cv_file__dev_ptmx=no > config.site
echo ac_cv_file__dev_ptc=no >> config.site
export CONFIG_SITE=config.site
./configure CC=mipsel-linux-gcc CXX=mipsel-linux-g++ --host=mipsel-linux --build=i386-linux-gnu --disable-ipv6
(3) 修改makefile
OPT= -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
一行中,去掉-g,我们不要debug python,-O3改为-O2,空间紧张O2就可以了。
PGEN= Parser/pgen$(EXE)
一行的下面加上 PGEN_HOST= ../build.pc/Parser/pgen$(EXE)
表明我们在HOST上运行的pgen,在要使用PGEN的地方改为PGEN_HOST:
$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
改为:
$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
-$(PGEN_HOST) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
修改所有使用新生成的python的地方。
所有如 ./$(BUILDPYTHON) 的地方,都改为python
2. libxml的编译 使用文件 libxml2-2.7.8
首先要将第1步编译出来的python加入交叉编译器中,步骤如下
(1) 修改/usr/include/python2.7/pyconfig.h 第24行 改为 # include
(2) 将/usr/include/i386-linux-gnu目录下的python2.7文件夹拷贝到交叉编译器mipsel-linux-gcc默认的include文件夹中
/finrod/buildroot-gcc342/lib/gcc/mipsel-linux-uclibc/3.4.2/include/i386-linux-gnu
(3) 将编译好的libpython2.7.a拷贝到交叉编译器的lib文件中 /finrod/buildroot-gcc342/lib
libxml的编译
./autogen.sh
./configure --host=mipsel-linux --prefix=/finrod/mips_lib/test_xml/libxml --enable-static=yes CC=mipsel-linux-gcc CXX=mipsel-linux-g++ --without-zlib
make
make install