Help using gcj and g++ together
Jeff Sadowski
jeff.sadowski@gmail.com
Thu Sep 13 21:56:00 GMT 2007
I have been trying to get g++ to compile some code using java compiled objects.
I'm using gcc and gcj versions
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.
following is the code I am having difficulty with
#!/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
More information about the Java
mailing list