This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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: g++ & gcj


On Mon, 23 Aug 2004, Dan Kegel wrote:
> Jari Korva wrote:
> > Then, if I explicitly add that directory using -I I get tons of
> > errors:
> >
> > arm-unknown-linux-gnu-g++ -I/opt/cross/arm-linux-3.4.0/include -o cni
> > cni-test.cpp -lgcj
> > In file included from
> > /opt/cross/arm-linux-3.4.0/include/java/lang/Object.h:16,
> >                  from /opt/cross/arm-linux-3.4.0/include/gcj/cni.h:16,
> >                  from cni-test.cpp:2:
> > /opt/cross/arm-linux-3.4.0/include/gcj/javaprims.h:90: error: stray '$' in
> > program ...
> >
> > Does anyone have a clue what's wrong? I've been trying both gcc 3.4.0 and
> > 3.4.1.
>
> Nope, other than perhaps you're trying to include Java source
> into a C++ program?  I've never played with gcj at all, so I'm
> pretty useless here.

No, it is a regular .h file. Native 3.4.0 compiler for x86 seem to parse
the same/similar file just fine, but for some reason arm cross-compilers
fail. I was using CNI hello world, which I found from the documentation:

     // compile with: g++ -o cni-test cni-test.cpp -lgcj

     #include <gcj/cni.h>
     #include <java/lang/System.h>
     #include <java/io/PrintStream.h>
     #include <java/lang/Throwable.h>

     int main(int argc, char *argv)
     {
       using namespace java::lang;

       try
       {
         JvCreateJavaVM(NULL);
         JvAttachCurrentThread(NULL, NULL);

         String *message = JvNewStringLatin1("Hello from C++");
         JvInitClass(&System::class$);
         System::out->println(message);

         JvDetachCurrentThread();
       }
       catch (Throwable *t)
       {
         System::err->println(JvNewStringLatin1(
           "Unhandled Java exception:"));
         t->printStackTrace();
       }
     }


- Jari

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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