gcj compile failed(newbie question)
Lars Andersen
lars@rimfaxe.com
Mon Mar 31 09:05:00 GMT 2003
On Mon, 2003年03月31日 at 04:37, Steve Ni wrote:
> gcj -shared -o jg jg.jar
>> try to compile a pure java project, gcj stop here:
>> C:/gcc-3.3/test/jg.jar: undefined reference to
> `org::xml::sax::EntityResolver::c
> lass$'
> C:\DOCUME~1\Steve\LOCALS~1\Temp/ccU7aaaa.o(.data+0x23748): In function
> `ZN3org10
> javagroups5stack17NakReceiverWindow8toStringEv':
> C:/gcc-3.3/test/jg.jar: undefined reference to
> `org::xml::sax::EntityResolver::c
> lass$'
> C:\DOCUME~1\Steve\LOCALS~1\Temp/ccU7aaaa.o(.data+0x238f4):C:/gcc-3.3/test/jg
> .jar
> : undefined reference to `org::xml::sax::ErrorHandler::class$'
Not all of the classes provided in jdk1.4 exists in GCJ.
Looks like you miss some xml stuff!
Have a look at xerces at http://xml.apache.org
(BTW I still use xerces1, because of my big collection of old code. You
know, if it works, don't replace it. I guess Xerces2 will work as well)
It contains the classes you miss.
XERCES HOWTO (note: I haven't actually tried this, since i don't have
jg.jar)
Compile xerces into a object file
# gcj -c xerces.jar -o xerces.o
Compile jg into a object file
# gcj -c jg.jar -o jg.o
Link'em together
# gcj -shared -o jg xerces.o jg.o
Xerces will work, but I find it a little too bulky myself. A nice
alternative is Sparta, which will work as a lightweight replacement for
xerces. find it at http://sparta-xml.sourceforge.net/
There you can find thermopylae as well, which provides an interface
making sparta behave like xerces.
To use it you must compile the interface part of xerces into a object
file. As you can see, this is the dom part only, since I don't use sax
parsers at all. You can easily do the same for the sax part.
# gcj -c \
org/w3c/dom/UserDataHandler.java \
org/w3c/dom/DOMErrorHandler.java \
org/w3c/dom/DOMError.java \
org/w3c/dom/DOMLocator.java \
org/w3c/dom/Attr.java \
org/w3c/dom/Document.java \
org/w3c/dom/NamedNodeMap.java \
org/w3c/dom/Node.java \
org/w3c/dom/NodeList.java \
org/w3c/dom/Text.java \
org/w3c/dom/Element.java \
org/w3c/dom/DOMImplementation.java \
org/w3c/dom/DOMException.java \
org/w3c/dom/CharacterData.java \
org/w3c/dom/CDATASection.java \
-o xerces_dom_interfaces.o
Then compile sparta.jar and thermopylae.jar to object files and link it
all into your application, like in the xerces example.
Performance in sparta is far superior to xerces, but it lacks some
features. Your choice.
Good luck!
/Lars Andersen
More information about the Java
mailing list