From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 6D306BC69 for ; Thu, 3 Jan 2008 21:07:24 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAP/MfEfUGyodimdsb2JhbACQDwEBAQgEBiIHmWs X-IronPort-AV: E=Sophos;i="4.24,240,1196636400"; d="scan'208";a="20883566" Received: from smtp3-g19.free.fr ([212.27.42.29]) by mail4-smtp-sop.national.inria.fr with ESMTP; 03 Jan 2008 21:07:24 +0100 Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id BF46C17B559; Thu, 3 Jan 2008 21:07:23 +0100 (CET) Received: from [192.168.0.4] (rke75-3-82-229-183-156.fbx.proxad.net [82.229.183.156]) by smtp3-g19.free.fr (Postfix) with ESMTP id 3989F17B59E; Thu, 3 Jan 2008 21:07:23 +0100 (CET) Message-ID: <477D3F76.6040401@frisch.fr> Date: Thu, 03 Jan 2008 21:03:02 +0100 From: Alain Frisch User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: David LONY Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Interface C and Caml References: <477CF73B.9050406@pragmadev.com> In-Reply-To: <477CF73B.9050406@pragmadev.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; frisch:01 frisch:01 ocamlopt:01 -output-obj:01 gcc:01 gcc:01 usr:01 lib:01 ocaml:01 cmx:01 stdlib:01 compiler:01 ocamlopt:01 -output-obj:01 -lm:01 David LONY wrote: > ocamlopt -output-obj truc.ml -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 truc.ml 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 truc.ml -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 So: gcc -o test test.o truc_main.o -L/usr/lib/ocaml/3.09.2 -lasmrun -lm -ldl -- Alain