From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25254 invoked by alias); 4 Dec 2007 13:20:23 -0000 Received: (qmail 25245 invoked by uid 22791); 4 Dec 2007 13:20:22 -0000 X-Spam-Check-By: sourceware.org Received: from valhalla.dre.Vanderbilt.Edu (HELO smtp.dre.vanderbilt.edu) (129.59.129.253) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 04 Dec 2007 13:20:16 +0000 Received: from [129.59.129.248] (sirion.dre.Vanderbilt.Edu [129.59.129.248]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by smtp.dre.vanderbilt.edu (Postfix) with ESMTP id 1A0E6FC063 for ; Tue, 4 Dec 2007 07:20:14 -0600 (CST) Subject: GCJ .jar to .so with native method From: Joe Hoffert To: gcc-help@gcc.gnu.org Content-Type: text/plain Date: Tue, 04 Dec 2007 13:20:00 -0000 Message-Id: <1196774413.3986.18.camel@sirion.dre.vanderbilt.edu> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-4.fc7) Content-Transfer-Encoding: 7bit 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/msg00074.txt.bz2 Hi. 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. Thanks! -Joe