This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
C++ and GCJ
- From: Szasz Pal <spacegcc at email dot ro>
- To: java at gcc dot gnu dot org
- Date: Wed, 5 Mar 2003 12:25:41 +0200
- Subject: C++ and GCJ
Hi!
I just started to work with GCJ.
I made a class (test):
--------8<--------
import java.io.*;
public class test
{
static public void main(String args[]){
System.out.println("Hello!");
}
int sqr(int num)
{
System.out.println("Hello from sqr!"); // !!
return num*num;
}
}
--------8<--------
and a main.cxx file:
--------8<--------
#include "test.h"
#include <stdio.h>
int main()
{
printf("IN main!\n");
int a=8;
printf("a=%d\n",a);
test tmp;
int b=tmp->sqr(a);
printf("b=%d\n",b);
return 0;
}
--------8<--------
Compile the test.java with gcj to .o, make a .class and .h
so I can access it from cxx, compile the main.cxx and link them
both (with g++)
If the line marked with "// !!" is missing, it works well,
but with it (System.out.println....) it gives me a segmentation fault.
Why ?
Well, first of all, this is a good way to combine C++ and Java ?
I need the both, because this way I can develop with rhide,
and I can use it's the debugging facility.
Szasz Pal
______________________________________________________________________
Do you want a free e-mail for life ? Get it at http://www.email.ro/