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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr 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 36A90BB84 for ; Sun, 11 Jan 2009 17:28:02 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.37,249,1231110000"; d="scan'208";a="21322521" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Jan 2009 17:28:02 +0100 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id n0BGS1uP011624 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 11 Jan 2009 17:28:01 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag8BACitaUnUGyoClGdsb2JhbACUEAEBAQEJCwgJEQO8IoVv X-IronPort-AV: E=Sophos;i="4.37,249,1231110000"; d="scan'208";a="22299682" Received: from smtp2-g21.free.fr ([212.27.42.2]) by mail1-smtp-roc.national.inria.fr with ESMTP; 11 Jan 2009 17:28:00 +0100 Received: from smtp2-g21.free.fr (localhost [127.0.0.1]) by smtp2-g21.free.fr (Postfix) with ESMTP id 49E5A4B00B3; Sun, 11 Jan 2009 17:27:54 +0100 (CET) Received: from [192.168.1.3] (che78-2-82-237-71-191.fbx.proxad.net [82.237.71.191]) by smtp2-g21.free.fr (Postfix) with ESMTP id DE2934B01B7; Sun, 11 Jan 2009 17:27:51 +0100 (CET) Message-ID: <496A1E07.9000108@inria.fr> Date: Sun, 11 Jan 2009 17:27:51 +0100 From: Xavier Leroy User-Agent: Thunderbird 2.0.0.4 (X11/20070620) MIME-Version: 1.0 To: Ben Jakb Cc: matthieu.dubuget@gmail.com, caml-list@inria.fr Subject: Re: [Caml-list] Shared libraries with ocamlopt callable from C (without main())? References: <49670917.3040103@gmail.com> In-Reply-To: X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 496A1E11.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocamlopt:01 callable:01 stdio:01 argc:01 argv:01 printf:01 argv:01 gcc's:01 command-line:01 -static:01 ocamlopt:01 -output-obj:01 gcc:01 ocamlc:01 -where:01 > ===== $ cat ./main.c ===== > #include > #include "libadd5wrapper.h" > int main (int argc,char **argv){ > printf("Gimme - %d \n", add5wrapper()); Should be add5wrapper(argv) -- as gcc's warnings told you. > return 0; > } > > Now I try to BUILD the whole thing: > [...] > Number 4 is where it breaks. I get a ton of errors and this is where > it ends for me. Because # 4 is also the point where I definitely have > no idea what I'm doing. Two things: - You're not linking in add5-prog.o as far as I can see - In static mode, the Unix linker is very picky about the relative order of -lxxx arguments on the command-line. For more information, see the Info pages for GNU ld. You probably don't need -static anyway. The following works: ocamlopt -output-obj add5.ml -o add5-prog.o gcc -I`ocamlc -where` -c add5wrapperlib.c gcc -c main.c gcc -o mainprog.opt main.o add5wrapperlib.o add5-prog.o \ -L`ocamlc -where` -lasmrun -ldl -lm Add "-static" to the last line if you know you really need it. Hope this puts you back on tracks. - Xavier Leroy