From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14196 invoked by alias); 26 Mar 2008 10:03:12 -0000 Received: (qmail 14186 invoked by uid 22791); 26 Mar 2008 10:03:11 -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; Wed, 26 Mar 2008 10:02:52 +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.8) with ESMTP id m2QA2pV3021798; Wed, 26 Mar 2008 06:02:51 -0400 Received: from zebedee.pink (vpn-14-46.rdu.redhat.com [10.11.14.46]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m2QA2nDT005518; Wed, 26 Mar 2008 06:02:50 -0400 Message-ID: <47EA1F49.7000107@redhat.com> Date: Wed, 26 Mar 2008 10:03:00 -0000 From: Andrew Haley User-Agent: Thunderbird 2.0.0.12 (X11/20080213) MIME-Version: 1.0 To: Lorenzo Pesce CC: gcc-help@gcc.gnu.org Subject: Re: Issue on X86_64? References: <4082B87F-8FC7-42FC-A5CE-EDC6A055621B@uchicago.edu> In-Reply-To: <4082B87F-8FC7-42FC-A5CE-EDC6A055621B@uchicago.edu> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 2008-03/txt/msg00252.txt.bz2 Lorenzo Pesce wrote: > Dear all, > I am preparing some free software that needs to work on different > platforms (OS X, windows, Linux x 32,64). > One problem I have is that this system is based upon a fortran core, a > set of routines that do statistical calculations, which is used > differently by either fortran, c or java drivers. > > I package the procedures (.o) in three formats: a libroc.a and libroc.so > and a libroc.so (as a jni lib). > I usually link the pieces of libgfortran.a (ar -x ...) so that users do > not need to have libgfortran on their system. I then include those > pieces when I build all the libraries. > > The three formats build and work fine under gcc-4.1.1 on OS X 10.4 (G4 > or Xeon) and Linux Intel 32. > > However, when I get to X86 (whether Intel or AMD) it does not work > anymore. I can compile the files, and build the static library libroc.a. > It works fine and I can move it from AMD to intel (not the other way > around, but I assume it is a problem with my installation). However, > when I try to build a dynamically linked library, gcc complains that > "Relocation R_X86_64_32 against 'a local symbol' can not be used when > making a share object; recompile with -fPIC" > then it tells me it can't read symbols .o because it is a bad value. You need to compile everything that goes into a dynamically linked library with -fPIC. > If I link the libgfortran.so or load the libgfortran.so it works for R. > However, the result works either on AMD or Intel. > > However, it does not work for the java jnilib because it thinks that it > is the wrong ELF class: ELFCLASS64 (which it is). I'm guessing you have a 32-bit JVM, so you'll need to compile the jni library with -m32. > I would like to use the .o's of libgfortran directly because that would > allow me to have a single library for both Intel and AMD and also to > make my development tree somewhat simpler. Not to mention that I would > like to understand what is happening. > > What am I doing wrong? I don't think you can have a single library with both 32-bit and 64-bit binaries. Andrew.