forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to compile libxml2

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
mokke



Joined: 04 Jun 2008
Posts: 1

PostPosted: Wed Jun 04, 2008 2:13 am    Post subject: How to compile libxml2 Reply with quote

Hi,

im trying to compile libxml2 for psp. but i cant compile libxml2 for psp.
ive seen the past topic about xml in this forum. and i tried to compile libxml2.
but failed. so i need help.

what i did :
install pspsdk, psplibraries.
download libxml2-2.6.32
compile libxml2 following below code. ... failed!

os : ubuntu
Code:
CC=psp-gcc CXX=psp-g++ LIBS="-lpspdebug -lpspdisplay -lpspge -lc -lpspuser -lpspkernel" LDFLAGS="-L/usr/local/pspdev/psp/sdk/lib" ./configure --host=mips --with-minimum --without-threads --without-writer --without-modules
make

but make stops with below error.

Code:
...
... ....
/.libs/libxml2.a(encoding.o): In function `xmlAddEncodingAlias':
/home/student/Desktop/libxml2-2.6.32/encoding.c:1000: relocation truncated to fit: R_MIPS_GPREL16 against `__ctype_ptr'
./.libs/libxml2.a(encoding.o): In function `xmlGetEncodingAlias':
/home/student/Desktop/libxml2-2.6.32/encoding.c:969: relocation truncated to fit: R_MIPS_GPREL16 against `__ctype_ptr'
./.libs/libxml2.a(encoding.o): In function `xmlParseCharEncoding':
/home/student/Desktop/libxml2-2.6.32/encoding.c:1106: relocation truncated to fit: R_MIPS_GPREL16 against `__ctype_ptr'
./.libs/libxml2.a(encoding.o): In function `xmlNewCharEncodingHandler':
/home/student/Desktop/libxml2-2.6.32/encoding.c:1270: relocation truncated to fit: R_MIPS_GPREL16 against `__ctype_ptr'
./.libs/libxml2.a(encoding.o): In function `xmlFindCharEncodingHandler':
/home/student/Desktop/libxml2-2.6.32/encoding.c:1598: relocation truncated to fit: R_MIPS_GPREL16 against `__ctype_ptr'
collect2: ld returned 1 exit status
make[2]: *** [xmllint] Error 1
make[2]: Leaving directory `/home/gsus/libxml/libxml2-2.6.24'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/gsus/libxml/libxml2-2.6.24'
make: *** [all] Error 2


do i need to add other code now? please help me.

Regards, mokke
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed Aug 06, 2008 3:08 pm    Post subject: Reply with quote

It's a big pain in the rear... here's how I did it.

Check out the latest libxml2 from their svn repo, or get an archive.

Edit Makefile.am: add "dup.c" after "xmlIO.c" on line 35.

Create a file in the libxml2 directory called "dup.c" and give it these contents:

Code:
#include <fcntl.h>

int
dup (int fd1) {
   return (fcntl (fd1, F_DUPFD, 0));
}


Run

Code:
./autogen.sh


Now edit config.sub: add

Code:
   psp)
      basic_machine=mipsallegrexel-psp
      os=-elf
      ;;


at line 883 (should be immediately after ps2 entry).

Now run

Code:
CFLAGS="-g -O2 -G0 -Wall" LDFLAGS="-L$(psp-config --psp-prefix)/lib -L$(psp-config --pspsdk-path)/lib"   LIBS="-lz -lc -lstdc++ -lpsplibc -lpspuser -lpspnet_inet -lpspnet_resolver"   ./configure --host=psp --disable-shared --prefix=$(psp-config --psp-prefix)


Now you're ready to "make". It should error out on "runtest.c". If so, you've got what you want. The tests are extraneous... I don't know WHY the official build tries to do them by default.

Now "make install". It'll again error out on the test. Now you have to complete the install by hand (you only got the includes).

Copy ".libs/libxml2.a" to "/usr/local/pspdev/psp/lib/".
Copy "libxml2.la" to "/usr/local/pspdev/psp/lib/".
Copy "libxml-2.0.pc" to "/usr/local/pspdev/psp/lib/pkgconfig/".

And you're done.

A couple thoughts: Only the i386 has dup() in newlib... does no one use it anymore? Was it moved somewhere else on other platforms? The dup.c above is from that i386 code. libxml2 relies on dup()... it's got to be SOMEWHERE. Either dup() and dup2() where moved out of newlib to someplace else (that doesn't exist on the PSP), or no one uses the svn version of libxml2. Secondly, why the hell do they try to compile AND RUN the tests by default? It should only do that if you tell it to. "make tests" for example. It's ridiculous that the default build makes every test known the mankind AND tries to run them. Finally, this library is HUGE. Is there a smaller xml library? Not tinyxml... that's C++. I mean a C lib for xml.

EDIT: to answer my last question, it looks like mini-xml might be better for xml on the PSP. I'll have to try it.

http://www.minixml.org/
Back to top
View user's profile Send private message AIM Address
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed Aug 06, 2008 5:01 pm    Post subject: Reply with quote

As a follow-up, I was able to successfully compile and test mini-xml. You need to configure with this:

Code:
CFLAGS="-G0" LDFLAGS="-L$(psp-config --psp-prefix)/lib -L$(psp-config --pspsdk-path)/lib"   LIBS="-lc -lstdc++ -lpsplibc -lpspuser"   ./configure --host=psp --disable-shared --disable-threads --prefix=$(psp-config --psp-prefix)


Then it'll compile. Like libxml2, this tries to compile a test app, which fails since we're cross-compiling. Folks just don't take that into consideration, do they?

You have to copy the lib and include file by hand, naturally.

I altered the test app to run on the PSP and tried it... works fine.
Back to top
View user's profile Send private message AIM Address
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Wed Aug 06, 2008 7:46 pm    Post subject: Reply with quote

Are you sure you need libxml2?
There is a parser called TinyXML, dunno if you know about it, it can be found here:
http://sourceforge.net/projects/tinyxml

I know it works on psp, I have seen is in bookr.
Id recomend you looking into bookr sources here:
http://sourceforge.net/projects/bookr/
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Aug 07, 2008 3:51 am    Post subject: Reply with quote

TinyXML is C++ only, not C. Mini-XML is C or C++, so it's better for the PSP.
Back to top
View user's profile Send private message AIM Address
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Thu Aug 07, 2008 4:35 am    Post subject: Reply with quote

Why is C better for psp than C++ ?
(just curious...)
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Aug 07, 2008 4:46 am    Post subject: Reply with quote

kralyk wrote:
Why is C better for psp than C++ ?
(just curious...)


Because it is. :P :D

What I mean is that many programs are C, not C++. You can't use a C++ library in a C program. Most programmers writing in C don't want to switch to C++ just to use XML. They're using C instead of C++ for a reason, and forcing them to switch to C++ just for one library is silly. So if your project is already C++, TinyXML is fine, but if your project is C, don't switch, use Mini-XML.
Back to top
View user's profile Send private message AIM Address
uberjack



Joined: 17 Jul 2007
Posts: 34
Location: California, USA

PostPosted: Thu Aug 07, 2008 4:56 am    Post subject: Reply with quote

J.F. wrote:
kralyk wrote:
Why is C better for psp than C++ ?
(just curious...)


Because it is. :P :D

What I mean is that many programs are C, not C++. You can't use a C++ library in a C program. Most programmers writing in C don't want to switch to C++ just to use XML. They're using C instead of C++ for a reason, and forcing them to switch to C++ just for one library is silly. So if your project is already C++, TinyXML is fine, but if your project is C, don't switch, use Mini-XML.


Yeah, but turning a C program into a C++ program is quite a simple task ;)
Granted, we're warned against using standard C libraries in C++, but who listens to warnings these days?

Actually, I do agree with J.F. if only because C is ubiquitous in the PSP community
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group