caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* small solved problem linking caml with Fortran
@ 1998-03-05  8:54 Basile STARYNKEVITCH
  0 siblings, 0 replies; only message in thread
From: Basile STARYNKEVITCH @ 1998-03-05  8:54 UTC (permalink / raw)
  To: caml-list


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.
----------------------------------------------------------------------






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-03-09  8:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-05  8:54 small solved problem linking caml with Fortran Basile STARYNKEVITCH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).