2013年5月3日星期五

[编译出错] 记一次 XML_Parser 出错的解决


有台机器的 git 有问题,而重新源码编译安装时报如下错:

http-push.c:14:19: error: expat.h: No such file or directory
http-push.c:856: warning: type defaults to ‘int’ in declaration of ‘XML_Char’
http-push.c:856: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
http-push.c: In function ‘lock_remote’:
http-push.c:927: error: ‘XML_Parser’ undeclared (first use in this function)
http-push.c:927: error: (Each undeclared identifier is reported only once
http-push.c:927: error: for each function it appears in.)
http-push.c:927: error: expected ‘;’ before ‘parser’
http-push.c:934: warning: implicit declaration of function ‘XML_SetUserData’
http-push.c:934: error: ‘parser’ undeclared (first use in this function)
http-push.c:935: warning: implicit declaration of function ‘XML_SetElementHandler’
http-push.c:937: warning: implicit declaration of function ‘XML_SetCharacterDataHandler’
http-push.c:937: error: ‘xml_cdata’ undeclared (first use in this function)
http-push.c:938: warning: implicit declaration of function ‘XML_Parse’
http-push.c:943: warning: implicit declaration of function ‘XML_ErrorString’
http-push.c:944: warning: implicit declaration of function ‘XML_GetErrorCode’
http-push.c:947: warning: implicit declaration of function ‘XML_ParserFree’
http-push.c: In function ‘remote_ls’:
http-push.c:1171: error: ‘XML_Parser’ undeclared (first use in this function)
http-push.c:1171: error: expected ‘;’ before ‘parser’
http-push.c:1178: error: ‘parser’ undeclared (first use in this function)
http-push.c:1181: error: ‘xml_cdata’ undeclared (first use in this function)
http-push.c: In function ‘locking_available’:
http-push.c:1245: error: ‘XML_Parser’ undeclared (first use in this function)
http-push.c:1245: error: expected ‘;’ before ‘parser’
http-push.c:1252: error: ‘parser’ undeclared (first use in this function)
make: *** [http-push.o] Error 1

google 了一下说需要安装 XML_Parser http://search.cpan.org/~toddr/XML-Parser-2.41/Parser.pm
下载安装的时候发现,它还依赖 expat http://sourceforge.net/projects/expat/

那就老老实实一步步来吧:
$ cd expat-2.1.0
$ ./configure --prefix=/home/work/local
$ make && make install

$ cd XML-Parser-2.41
$ perl Makefile.PL PREFIX=/home/work/local INSTALLDIRS=perl EXPATLIBPATH=/home/work/local/lib EXPATINCPATH=/home/work/local/include
$ make && make install

$ vi ~/.bashrc 加入新内容

export LD_LIBRARY_PATH=/home/work/local/lib
export C_INCLUDE_PATH=/home/work/local/include
export LIBRARY_PATH=/home/work/local/lib

然后再编译,就没有再报错了.





没有评论: