Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Interface C and Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alain Frisch <alain@f...>
Subject: Re: [Caml-list] Interface C and Caml
David LONY wrote:
> ocamlopt -output-obj -o truc.o
> gcc -c test.c
> gcc -o test test.o truc.o -L/usr/lib/ocaml/3.09.2 -lasmrun

Two problems here:

1. the first line first compiles into truc.cmx/truc.o as usual, 
and then combine truc.o with stdlib.a and a temporary startup object 
into truc.o. It seems that the linker first creates a fresh truc.o file 
before reading the existing truc.o, so the native code produced by the 
compiler is actually lost. You should use a different file name:

ocamlopt -output-obj -o truc_main.o

2. the last line should mention the -lm and -ldl libraries, as can be 
found by:

   grep NATIVECCLIBS `ocamlc -where`/Makefile.config


gcc -o test test.o truc_main.o -L/usr/lib/ocaml/3.09.2 -lasmrun -lm -ldl

-- Alain