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=none autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id B2EA9BC69 for ; Fri, 4 Jan 2008 10:19:31 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAFuIfUdQDPIakGdsb2JhbACQEAEBAQEHBAQkB5ozghg X-IronPort-AV: E=Sophos;i="4.24,244,1196636400"; d="scan'208";a="7432255" Received: from smtp20.orange.fr ([80.12.242.26]) by mail3-smtp-sop.national.inria.fr with ESMTP; 04 Jan 2008 10:19:31 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2003.orange.fr (SMTP Server) with ESMTP id 1F1421C0012C for ; Fri, 4 Jan 2008 10:19:29 +0100 (CET) Received: from [192.168.1.5] (ASt-Lambert-152-1-62-107.w82-120.abo.wanadoo.fr [82.120.199.107]) by mwinf2003.orange.fr (SMTP Server) with ESMTP id D46B21C0011F; Fri, 4 Jan 2008 10:19:28 +0100 (CET) X-ME-UUID: 20080104091928870.D46B21C0011F@mwinf2003.orange.fr Message-ID: <477DFB4F.4000105@pragmadev.com> Date: Fri, 04 Jan 2008 10:24:31 +0100 From: David LONY Organization: PRAGMADEV User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: Alain Frisch Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Interface C and Caml References: <477CF73B.9050406@pragmadev.com> <477D3F76.6040401@frisch.fr> In-Reply-To: <477D3F76.6040401@frisch.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; 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 -ldl:01 It work well!! Thanks a lot Alain David Alain Frisch a écrit : > 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 > >