From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yquem.inria.fr (Postfix, from userid 18180) id 45918BB81; Sun, 12 Dec 2004 10:04:46 +0100 (CET) Date: Sun, 12 Dec 2004 10:04:46 +0100 From: Xavier Leroy To: Taras Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] ocamlopt and linking Message-ID: <20041212090446.GA30925@yquem.inria.fr> References: <41BBF35D.9060809@shaw.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41BBF35D.9060809@shaw.ca> User-Agent: Mutt/1.3.28i X-Spam: no; 0.00; caml-list:01 ocamlopt:01 ocaml:01 htmlman:01 libasmrun:01 usr:01 lib:01 ocaml:01 -ldl:01 -lm:01 -lcurses:01 command-line:01 gcc:01 unix:01 defined:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=-2.8 required=5.0 tests=ALL_TRUSTED autolearn=disabled version=3.0.0 X-Spam-Level: > I'm trying to link an ocamlopt-generated object file into a C program by > following instructions on http://caml.inria.fr/ocaml/htmlman/manual032.html > Currently it seems that main is already defined in libasmrun and some > symbols are missing from it. > cc -L /usr/lib/ocaml -lasmrun -ldl -lm -lcurses -o prog modwrap.o > mod_from_ml.o main.c You have a linking order problem. Remember that Unix linkers are *very* sensitive to the order of libraries on the command-line. (See the Info page for gcc, section "Options for linking", for more info.) Just put the libraries (-lxxx) last on the line and everything will work fine. - Xavier Leroy