public inbox for rhug-rhats@sourceware.org
 help / color / mirror / Atom feed
* compiling antlr with gcj
@ 2003-07-11  1:00 paul taney
  2003-07-11  2:06 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: paul taney @ 2003-07-11  1:00 UTC (permalink / raw)
  To: rhug-rhats

rhug-arhats,

This discussion is taking place on the antlr-interest
list.  A senior developer of antlr and I are engaged
in trying to compile antlr with gcj.  We have gotten
it to compile but are having link problems on
 
    Throwable.java

Could you please comment on the error we're getting?

We would appreciate it so much.  If you don't know,
antlr is an advanced parser generator at

    http://antlr.org

Sincerely,
paul

---<what follows is from antlr-interest@yahoo.com> ---

Loring,

I have put the --classpath back into the script
and added this to that path:

    /usr/local/gcc/gcc-3.3/libjava/java/lang

because that's were gcc's Throwable lives.  And 
added ".o" to the -o arg (because it complained 
that antlr was a dir).

Now the $CLASSPATH is
/usr/local/gcc/gcc-3.3/libjava:\
/usr/local/gcc/gcc-3.3/build/i686-pc-linux-gnu/libjava:\
/usr/local/gcc/gcc-3.3/libjava/java/lang:\
/usr/local/java/j2sdk1.4.2:\
/usr/local/java/j2sdk1.4.2/bin:\
/usr/local/jython-2.1:.

and the compile script is:

gcj --classpath $CLASSPATHGNU -o antlr.o --main=Tool \
         antlr/*.java \
         antlr/actions/cpp/*.java \
         antlr/actions/csharp/*.java \
         antlr/actions/java/*.java \
         antlr/build/*.java \
         antlr/collections/*.java \
         antlr/collections/impl/*.java \
         antlr/debug/*.java \
         antlr/preprocessor/*.java


Still we have:

/tmp/ccfeKrb0.o: In function
`antlr::ANTLRError::ANTLRError(void)':
/usr/local/antlr/antlr-2.7.2/antlr/ANTLRError.java(.data+0x44):
undefined reference to
`java::lang::Throwable::getCause(void)'
/usr/local/antlr/antlr-2.7.2/antlr/ANTLRError.java(.data+0x48):
undefined reference to
`java::lang::Throwable::initCause(java::lang::Throwable
*)'
/usr/local/antlr/antlr-2.7.2/antlr/ANTLRError.java(.data+0x5c):
undefined reference to
`java::lang::Throwable::getStackTrace(void)'
/usr/local/antlr/antlr-2.7.2/antlr/ANTLRError.java(.data+0x60):
undefined reference to
`java::lang::Throwable::setStackTrace(JArray<java::lang::StackTraceElement
*> *)'
<snip>

$ grep getCause $PATH/Throwable.java
  public Throwable getCause()
   * Then if <code>getCause()</code> doesn't return
null it adds a line
    Throwable cause = getCause();
        cause = cause.getCause();


Anybody have a clue?

paul


--- lgcraymer <lgc@mail1.jpl.nasa.gov> wrote:
> All--
> 
> Since Paul and I took this discussion offline (my
> role has been 
> mostly to interpret the compiler error messages
> while he does all the 
> real work), he has made some impressive progress. 
> After adding a few 
> type casts to the ANTLR source, all of ANTLR
> compiles and we appear to 
> be down to one link error--java.lang.Throwable
> methods cannot be 
> found.
> 
> At this point, our best guess is that this is fixed
> in the version of 
> gcj used by RHUG
> (<http://sources.redhat.com/rhug/>--they call for a 
> recent development snapshot) to get all of their
> Java projects to 
> compile (some of which are more demanding than
> ANTLR).  Unfortunately, 
> Paul is stuck with a slow connection and has a
> family emergency to 
> attend to, and I'm spending my spare time trying to
> prepare for this 
> weekend's discussions.  We won't be able to take the
> last small steps 
> for several days.  If anyone out there wants to
> produce an executable 
> sooner, you have our blessings.  I'll post his diffs
> and compilation 
> script (neither of us have yet looked into gcj
> makefiles) below.
> 
> --Loring
> 

<snip>



__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: compiling antlr with gcj
  2003-07-11  1:00 compiling antlr with gcj paul taney
@ 2003-07-11  2:06 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2003-07-11  2:06 UTC (permalink / raw)
  To: paul taney; +Cc: rhug-rhats

>>>>> "paul" == paul taney <paultaney@yahoo.com> writes:

paul> Now the $CLASSPATH is
paul> /usr/local/gcc/gcc-3.3/libjava:\
paul> /usr/local/gcc/gcc-3.3/build/i686-pc-linux-gnu/libjava:\
paul> /usr/local/gcc/gcc-3.3/libjava/java/lang:\
paul> /usr/local/java/j2sdk1.4.2:\
paul> /usr/local/java/j2sdk1.4.2/bin:\
paul> /usr/local/jython-2.1:.

Let's talk about this a bit.
Why do you have all these things in CLASSPATH?

In general, don't put the JDK stuff in the class path.
Second, you shouldn't need to tell gcj where to find the default
classes -- it should find them by itself.

If you really need to do something like this, point gcj at the
installed libgcj-<version>.jar file.  It is in <prefix>/share/java,
where <prefix> depends on how you configured gcc.

paul> gcj --classpath $CLASSPATHGNU -o antlr.o --main=Tool \
paul>          antlr/*.java \
paul>          antlr/actions/cpp/*.java \
paul>          antlr/actions/csharp/*.java \
paul>          antlr/actions/java/*.java \
paul>          antlr/build/*.java \
paul>          antlr/collections/*.java \
paul>          antlr/collections/impl/*.java \
paul>          antlr/debug/*.java \
paul>          antlr/preprocessor/*.java

I recommend naming the output file "antlr" instead of "antlr.o".
This shouldn't matter, but it is weird and a little confusing.

Finally, gcj links with the libgcj.so library.  Make sure you are
linking against the right one.  This is probably your problem.

My guess is that, since you installed gcc in a non-standard location,
the linker is finding the wrong libgcj.  Link with "gcj -v" to see
what is going on.

I usually link like this:

gcj -o foo ... -Wl,-rpath,<prefix>/lib

This is an ugly hack to make the resulting executable find the
resulting libgcj.so at runtime.  The gcc project made a decision not
to have the compiler do this automatically; I don't remember why.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-07-11  2:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-11  1:00 compiling antlr with gcj paul taney
2003-07-11  2:06 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).