This is the mail archive of the java@gcc.gnu.org mailing list for the Java 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]

where to learn how to use java objects in C++


I have been trying to get just a simple usage of a simple java class
but when I compile it into a binary I get a Segmentation fault and I'm
not sure how much further I can go.
I'll examine it with valgrind but I think I'm missing something in how gcj works

I'm using fedora core 6
gcc --version
gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and what follows is what others can use to build my simple test case

#!/bin/bash
cat << END > Makefile.pretab
cfive: five.h five.o cfive.cc
<tab>g++ -Wall --pedantic -o cfive cfive.cc five.o -lgcj -lstdc++

five.o: five.class
<tab>gcj -Wall --pedantic -c five.class

five.class: five.java
<tab>gcj -Wall --pedantic -C five.java

five.h: five.class
<tab>gcjh five

clean:
<tab>rm -f five.class five.o five.h
END

cat Makefile.pretab | sed s/\<tab\>/\\t/g >Makefile
rm -f Makefile.pretab

cat << END > five.java
public class five
{
 public static int hello()
 {
  return 5;
 }
 public static void main(String argv[])
 {
  System.out.println(hello());
 }
}
END
cat << END > cfive.cc
#include <iostream>
#include <gcj/cni.h>
#include "five.h"

int main(int argc,char **argv)
{
 int test=0;
 test=(int)five::hello();
 std::cout<<test<<"\n";
 return 0;
}
END

make

./cfive


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