[jnc-users] SWT compile
Status: Beta
Brought to you by:
soapy
From: Lee D. P. <le...@3s...> - 2007-02-16 22:25:02
|
Hi Marco, I had previously had problems with an AWT compile, which after your help I was able to get working. The corrupted GIF image issue however meant that we cannot use the compiled .exe so we decided to add an SWT GUI to our agent, which honestly looks much better but I'm now seeing errors when attempting to build this. A search in our source code shows no trace of AWT or Swing, and the compile completes with the exclude GUI option. The problem lies in linking; here are some the errors I'm seeing. Any advice would be very much appreciated.=20 I'm trying to build Windows .exe on Windows with gcc-119844-win. c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- mingw32/4.2.0/../../../libgcj.a(gui_java_awt.o):gui_java_awt.zip:(.text+ 0x20): multiple definition of `java::awt::AWTPermission::AWTPermission(java::lang::String*)' =09 c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- mingw32/4.2.0/../../../libjncNoGui.a:noGui.jar:(.text+0x290): first defined here =09 c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- mingw32/4.2.0/../../../libgcj.a(gui_java_awt.o):gui_java_awt.zip:(.text+ 0xaa0): multiple definition of `java::awt::Button::Button(java::lang::String*)' =09 c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- mingw32/4.2.0/../../../libjncNoGui.a:noGui.jar:(.text+0x2d0): first defined here =09 c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- mingw32/4.2.0/../../../libgcj.a(gui_java_awt.o):gui_java_awt.zip:(.text+ 0xc8f0): multiple definition of `java::awt::GridBagConstraints::GridBagConstraints(int, int, int, int, double, double, int, int, java::awt::Insets*, int, int)' =09 c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- mingw32/4.2.0/../../../libjncNoGui.a:noGui.jar:(.text+0x150): first defined here =09 c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- mingw32/4.2.0/../../../libgcj.a(gui_java_awt.o):gui_java_awt.zip:(.text+ 0xca70): multiple definition of `java::awt::GridBagLayout::GridBagLayout()' =09 c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- mingw32/4.2.0/../../../libjncNoGui.a:noGui.jar:(.text+0x130): first defined here =09 c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- Regards Lee > -----Original Message----- > From: jav...@li... > [mailto:jav...@li...] On Behalf Of > Marco Trudel > Sent: 15 February 2007 08:02 > To: Steven Blade; A mailing list for general questions and discussions. > Subject: Re: [jnc-users] [javaCompiler-users] compiles and executes but > throws java exception --help >=20 > Please always do "reply all", else we loose the mailinglist... >=20 >=20 > Steven Blade wrote: > > ok sure thing but please show me where to use the static block of code > ok. >=20 > Thanks for the sample. Just put that code in an own class (as the > attached XmlLoader.java) and add this class to the JNC compilation > source. This will ensure that the needed objects are pulled into the > binary. > You do not have to change your source. >=20 >=20 > > did it work both ways with you reading and transforming xml ? >=20 > Reading works, writing (transforming) fails. I'll create a bugreport > (it's probably a GNU classpath bug) and hope that the fix will be in JNC > 1.2. >=20 > > one more thing does that mean i have to use gnu's jar instead of java's > ? >=20 > No, you only have to ensure that your binary contains the xml stuff. > This is done with the static initializer since it references the xml > stuff and thus ld - the linker - will add them. >=20 >=20 > Marco >=20 >=20 > > import java.io.BufferedReader; > > import java.io.File; > > import java.io.InputStreamReader; > > > > import javax.xml.parsers.SAXParser; > > import javax.xml.parsers.SAXParserFactory; > > import javax.xml.transform.OutputKeys; > > import javax.xml.transform.Transformer; > > import javax.xml.transform.sax.SAXTransformerFactory; > > import javax.xml.transform.sax.TransformerHandler; > > import javax.xml.transform.stream.StreamResult; > > > > import org.xml.sax.Attributes; > > import org.xml.sax.SAXException; > > import org.xml.sax.helpers.AttributesImpl; > > import org.xml.sax.helpers.DefaultHandler; > > > > > > public class Foo extends DefaultHandler{ > > > > /** > > * @param args > > */ > > private static File file; > > private static String contents; > > private static Foo f=3Dnew Foo(); > > public static void main(String[] args) { > > // TODO Auto-generated method stub > > System.out.print("enter location of xml file to read "); > > BufferedReader input=3Dnew BufferedReader(new > InputStreamReader(System.in)); > > try > > { > > String sfile=3Dinput.readLine(); > > file=3Dnew File(sfile); > > readXml(); > > System.out.print(contents); > > writeXml(); > > }catch(Exception _){_.printStackTrace();} > > } > > private static void writeXml() > > { > > SAXTransformerFactory > factory=3D(SAXTransformerFactory)SAXTransformerFactory.newInstance(); > > try{ > > StreamResult stream=3Dnew StreamResult(System.out); > > TransformerHandler handler=3Dfactory.newTransformerHandler(); > > Transformer trans=3Dhandler.getTransformer(); > > trans.setOutputProperty (OutputKeys.ENCODING,"ISO-8859-1"); > > trans.setOutputProperty(OutputKeys.INDENT,"yes"); > > handler.setResult(stream); > > handler.startDocument(); > > AttributesImpl atts=3Dnew AttributesImpl(); > > handler.startElement("", "", "test", atts); > > atts.clear(); > > handler.startElement("", "", "foo", atts); > > handler.characters(new char[]{'a','b','c'}, 0, 3); > > handler.endElement("", "", "foo"); > > handler.endElement("", "", "test"); > > handler.endDocument(); > > }catch(Exception _){_.printStackTrace();} > > } > > > > private static void readXml() > > { > > System.out.println("reading xml..."); > > try{ > > SAXParserFactory factory=3DSAXParserFactory.newInstance(); // the > exception points to this line > > factory.setValidating(false); > > SAXParser parser=3Dfactory.newSAXParser(); > > parser.parse (file, f.new OwnHandler()); > > } > > catch(Exception _){_.printStackTrace();} > > } > > > > private class OwnHandler extends DefaultHandler{ > > > > public void startElement(String namespaceURI, > > String sName, > > String qName, > > Attributes attrs) throws SAXException{ > > contents+=3D"<"+qName+">"; > > } > > public void endElement(String uri, String localName, String qName) > throws SAXException{ > > contents+=3D"<"+qName+"/>"; > > } > > public void characters(char[] buf,int offset,int length)throws > SAXException{ > > contents+=3Dnew String(buf,offset,length); > > } > > } > > } > > > > > > > > > > ------------------------------------------------------------------------ > > > > <?xml version=3D1.0 encoding=3DUTF-8?> > > <test> > > <line>testing java native compiler</line> > > </test> |