Error compiling ruby-libxml

hello

I just downloaded ruby-libxml-20020709
and tried to compile it on my linux machine

I have
ruby 1.6.6
and
libxml 2.4.22

I get this error after calling make:

gcc -fPIC -g -O2 -g -Wall -I/usr/local/include -I/usr/local/include/libxml2
-I/usr/local/include/libxml2 -I/usr/local/lib/ruby/1.6/i686-linux -I.
-I/usr/local/include -DHAVE_ZLIB_H -DHAVE_DOCBCREATEFILEPARSERCTXT -c -o
ruby_xml_sax_parser.o ruby_xml_sax_parser.c
ruby_xml_sax_parser.c: In function ruby_xml_sax_parser_new': ruby_xml_sax_parser.c:21: parse error beforeemptySAXHandlerStruct’
ruby_xml_sax_parser.c:52: `emptySAXHandlerStruct’ undeclared (first use in
this function)
ruby_xml_sax_parser.c:52: (Each undeclared identifier is reported only once
ruby_xml_sax_parser.c:52: for each function it appears in.)
make: *** [ruby_xml_sax_parser.o] Error 1

markus

Markus Jais mjais@web.de wrote in message news:CESW8.3$Sg1.937@news.ecrc.de

I just downloaded ruby-libxml-20020709
and tried to compile it on my linux machine

I have
ruby 1.6.6
and
libxml 2.4.22

I get this error after calling make:

gcc -fPIC -g -O2 -g -Wall -I/usr/local/include -I/usr/local/include/libxml2
-I/usr/local/include/libxml2 -I/usr/local/lib/ruby/1.6/i686-linux -I.
-I/usr/local/include -DHAVE_ZLIB_H -DHAVE_DOCBCREATEFILEPARSERCTXT -c -o
ruby_xml_sax_parser.o ruby_xml_sax_parser.c
ruby_xml_sax_parser.c: In function ruby_xml_sax_parser_new': ruby_xml_sax_parser.c:21: parse error before emptySAXHandlerStruct’
ruby_xml_sax_parser.c:52: `emptySAXHandlerStruct’ undeclared (first use in
this function)
ruby_xml_sax_parser.c:52: (Each undeclared identifier is reported only once
ruby_xml_sax_parser.c:52: for each function it appears in.)
make: *** [ruby_xml_sax_parser.o] Error 1

same here.

FreeBSD 4.6
gcc 2.95.3 20010315
Ruby 1.6.7 (although not that relevant ;))

FreeBSD 4.6
gcc 2.95.3 20010315

Put the declaration and initialisation of emptySAXHandlerStruct *before*
the first statement `rxsp = (ruby_xml_sax_parser *) ...'

Guy Decoux

ts decoux@moulon.inra.fr wrote in message news:200207161327.g6GDRa420903@moulon.inra.fr

FreeBSD 4.6
gcc 2.95.3 20010315

Put the declaration and initialisation of emptySAXHandlerStruct before
the first statement `rxsp = (ruby_xml_sax_parser *) …’

worked!

thx!
I am not that familiar with c, still after having looked at it, it
seems obvious. Does the original code work (first reference before
declaration) on other compilers?

I just downloaded ruby-libxml-20020709
and tried to compile it on my linux machine

I have
ruby 1.6.6
and
libxml 2.4.22

I get this error after calling make:

gcc -fPIC -g -O2 -g -Wall -I/usr/local/include -I/usr/local/include/libxml2
-I/usr/local/include/libxml2 -I/usr/local/lib/ruby/1.6/i686-linux -I.
-I/usr/local/include -DHAVE_ZLIB_H -DHAVE_DOCBCREATEFILEPARSERCTXT -c -o
ruby_xml_sax_parser.o ruby_xml_sax_parser.c
ruby_xml_sax_parser.c: In function ruby_xml_sax_parser_new': ruby_xml_sax_parser.c:21: parse error before emptySAXHandlerStruct’
ruby_xml_sax_parser.c:52: `emptySAXHandlerStruct’ undeclared (first use in
this function)
ruby_xml_sax_parser.c:52: (Each undeclared identifier is reported only once
ruby_xml_sax_parser.c:52: for each function it appears in.)
make: *** [ruby_xml_sax_parser.o] Error 1

For some reason, this works on gcc 3.1 and there weren’t any problems.
::shrug:: I’ve updated CVS to handle this error. The SAX parser isn’t
close to being done though, so I wouldn’t worry about trying to use
it. You can create a SAX parser object, but it does nothing for you.
libxml has a really tricky memory structure and the order in which
memory gets free’ed seems to be. I think what I need to do is setup a
destructor… libxml has its own memory mallocing that I haven’t
figured how to get working in a nice way with Ruby. I’ve gotten the
DOM interface all balanced out and working nicely, but the SAX stub
needs work. Just don’t use it for now. :~) -sc

PS Here’s a new version:

http://www.rubynet.org/modules/xml/ruby-libxml/

I’ll update the port in a day or so when I finish libxslt. ::grin::

···


Sean Chittenden

I am not that familiar with c, still after having looked at it, it
seems obvious. Does the original code work (first reference before
declaration) on other compilers?

On some strange compiler, yes :-))

For the original author try

   require 'libxml'

   a = XML::SaxParser.new
   GC.start
   b = XML::SaxParser.new

and see the value of *rxsp->xsh when ruby_xml_sax_parser_free is called

Also, little memory leak.

Guy Decoux