From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22987 invoked by alias); 10 Jun 2009 09:40:08 -0000 Received: (qmail 22975 invoked by uid 22791); 10 Jun 2009 09:40:07 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,J_CHICKENPOX_44,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-fx0-f222.google.com (HELO mail-fx0-f222.google.com) (209.85.220.222) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Jun 2009 09:40:00 +0000 Received: by fxm22 with SMTP id 22so689827fxm.8 for ; Wed, 10 Jun 2009 02:39:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.215.15 with SMTP id s15mr615567muq.118.1244626797261; Wed, 10 Jun 2009 02:39:57 -0700 (PDT) Date: Wed, 10 Jun 2009 09:40:00 -0000 Message-ID: Subject: How to convert a jar into so file and use it ? From: David Michel To: java@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-06/txt/msg00030.txt.bz2 Hello, I have a very simple java test code that uses a public method called 'coucou' of a external jar called 'Hello.jar' which contains the package 'hello' and the public class 'Hello'. Here is the test code Tool.java: import hello.Hello; public class Tool { public static void main(String[] args) { System.out.println("main program running"); Hello.coucou(); } } which I would usually compile, with the following commands: $ gcj -O0 -g0 -C Tool.java --classpath=./:extern/Hello.jar $ gij -cp .:extern/Hello.jar Tool Now if I want to compile Tool.java natively with gcj, what do I need to do ? I can create the shared library from the jar like this: $ gcj -O0 -g0 -shared -findirect-dispatch -fjni -fPIC extern/Hello.jar -o extern/Hello.jar.so I can then compile Tool.java into Tool.o with: $ gcj -O0 -g0 --classpath=./:extern/Hello.jar -c Tool.java -o Tool.o (altough this is using the jar and not the so ??) But then, I'm stuck with creating the final executable, i.e. Tool.out Any clues ? Cheers David