This is the mail archive of the rhug-rhats@sources.redhat.com mailing list for the RHUG project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: compiling antlr with gcj


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]