From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA02054 for caml-redistribution; Mon, 9 Mar 1998 09:14:24 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA17181 for ; Thu, 5 Mar 1998 09:54:11 +0100 (MET) Received: from nenuphar.saclay.cea.fr (nenuphar.saclay.cea.fr [132.166.192.7]) by nez-perce.inria.fr (8.8.7/8.8.5) with ESMTP id JAA05210 for ; Thu, 5 Mar 1998 09:54:10 +0100 (MET) Received: from orion.serma.cea.fr (orion.serma.cea.fr [132.166.151.161]) by nenuphar.saclay.cea.fr (8.8.8/CEAnet-relay-4.0.3) with ESMTP id JAA20358 for ; Thu, 5 Mar 1998 09:54:09 +0100 (MET) Received: (from basile@localhost) by orion.serma.cea.fr (8.8.7/8.8.7) id JAA04199; Thu, 5 Mar 1998 09:54:51 +0100 Date: Thu, 5 Mar 1998 09:54:51 +0100 Message-Id: <199803050854.JAA04199@orion.serma.cea.fr> From: Basile STARYNKEVITCH MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit To: caml-list@inria.fr Subject: small solved problem linking caml with Fortran X-Mailer: VM 6.34 under 20.3 "Vatican City" XEmacs Lucid Sender: weis This is mainly for ocaml developers but perhaps some users might have an insight. Caml (ocaml-1.07 bytecode compiler &interpreter) is used here as an embedding langage for numerical applications programmed in Fortran. Plateform is a Linux/Intel Pentium II. Kernel is 2.0.33, distribution is (patched) Redhat-5.0, libc is libc-2.0.6.so, binutils is 2.8.1.0.1 (not .0.15!), egcs-1.0.1 compiler suite (including f77 & libf2c) The problem is that both fortran's /usr/lib/libf2c.a and caml's /usr/local/lib/ocaml/libcamlrun.a defines a main function (in amain.o member) The custom top level is built with ocamlmktop -custom -o toplevel fthebase.cmo fthebasec.o F*.o -cclib /usr/lib/libf2c.a fthebasec.o is built from fthebasec.c. it is a C wrapper calling fortran routines and prividing ocaml C custom primitives fthebase.cmo is customer's Caml code F*.o is built from fortran77 F*.f sources The problem is that ocaml first links in the provided (Fortran's) /usr/lib/libf2c.a and then the caml's /usr/local/lib/ocaml/libcamlrun.a So Fortran's main.o is being loaded, and caml's main.o is not loaded. The solving hack is to extract the main.o from /usr/local/lib/ocaml/libcamlrun.a and rename it as camlmain.o build the top level with ocamlmktop -custom -o toplevel camlmain.o fthebase.cmo fthebasec.o F*.o -cclib /usr/lib/libf2c.a My suggestion is either to document it in the manual, or better to explicitly provide in /usr/local/lib/ocaml/ the camlmain.o object file. I also believe that the caml's /usr/local/lib/libcamlrun.a should be linked by ocaml before additional -cclib-ed libraries. I also would like an undocumented -dkeep option which would keep all temporary files that ocaml creates (gcc has a similar flag -save-temps). Having such an option would satisfy my curiosity :-) and probably help debug such problems. Thanks for all. N.B. Any opinions expressed here are solely mine, and not of my organization. N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA. ---------------------------------------------------------------------- Basile STARYNKEVITCH ---- Commissariat à l Energie Atomique DRN/DMT/SYSCO * CEA/Saclay bat.460 * 91191 GIF/YVETTE CEDEX * France fax: (33) 01,69.08.96.96; phone: 01,69.08.40.66; home: 01,46.65.45.53 email: Basile . Starynkevitch @ cea . fr (but remove white space) I speak french, english, russian. Je parle français, anglais, russe. ----------------------------------------------------------------------