From: Basile STARYNKEVITCH <basile.starynkevitch@cea.fr>
To: caml-list@inria.fr
Subject: small solved problem linking caml with Fortran
Date: Thu, 5 Mar 1998 09:54:51 +0100 [thread overview]
Message-ID: <199803050854.JAA04199@orion.serma.cea.fr> (raw)
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.
----------------------------------------------------------------------
reply other threads:[~1998-03-09 8:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199803050854.JAA04199@orion.serma.cea.fr \
--to=basile.starynkevitch@cea.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox