From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29662 invoked by alias); 4 Dec 2007 13:28:15 -0000 Received: (qmail 29653 invoked by uid 22791); 4 Dec 2007 13:28:14 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 04 Dec 2007 13:28:00 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.1) with ESMTP id lB4DRw6s012687 for ; Tue, 4 Dec 2007 08:27:58 -0500 Received: from zebedee.littlepinkcloud.COM (vpn-14-8.rdu.redhat.com [10.11.14.8]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lB4DRvMw006889; Tue, 4 Dec 2007 08:27:58 -0500 Received: from littlepinkcloud.COM (localhost.localdomain [127.0.0.1]) by zebedee.littlepinkcloud.COM (8.13.8/8.13.5) with ESMTP id lB4DRtKq026801; Tue, 4 Dec 2007 13:27:56 GMT Received: (from aph@localhost) by littlepinkcloud.COM (8.13.8/8.13.5/Submit) id lB4DRsha026797; Tue, 4 Dec 2007 13:27:54 GMT MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18261.21978.841368.32225@zebedee.pink> Date: Tue, 04 Dec 2007 13:28:00 -0000 From: Andrew Haley To: Joe Hoffert Cc: gcc-help@gcc.gnu.org Subject: Re: GCJ .jar to .so with native method In-Reply-To: <1196774413.3986.18.camel@sirion.dre.vanderbilt.edu> References: <1196774413.3986.18.camel@sirion.dre.vanderbilt.edu> X-Mailer: VM 7.19 under Emacs 22.0.93.1 X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2007-12/txt/msg00076.txt.bz2 Joe Hoffert writes: > I'm running into some problems converting a Java library (i.e., .jar > file) into a native shared library (i.e., .so file) and then using that > library with g++. In particular, I have a native method in the .jar file > that I can't figure out how to define to the linker's satisfaction. I'm > using GCC 4.1.2 on Linux. > > If I modify the gcjh-generated header file and define the native method > inline (e.g., virtual void receive(JArray< jbyte > *, jint) {} ) the > linker still complains about an undefined reference for the native > method: > > .//libricochet.so: undefined reference to `void > multishot::examples::RicochetApp::receive(JArray*, int)' > collect2: ld returned 1 exit status > > If I define the native method outside of the header file (e.g., in a C++ > source file like so: > void multishot::examples::RicochetApp::receive(JArray< jbyte > *, jint) > {} ) then the linker complains about a hidden symbol: > > /usr/bin/ld: RicochetApp: hidden symbol `void > multishot::examples::RicochetApp::receive(JArray*, int)' > in .obj/RicochetAppMain.o is referenced by DSO > /usr/bin/ld: final link failed: Nonrepresentable section on output > > Any ideas as to what I need to do to rectify my problem would be greatly > appreciated. This seems odd; we link C++ and Java code all the time. Is it possible for you to reduce your problem to a small test case? Then we can see what's going wrong. I think you're linking incorrectly, but at the moment that's just a wild guess. Andrew. -- Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK Registered in England and Wales No. 3798903