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=2.2 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 0F1F9BBC4 for ; Fri, 20 Mar 2009 13:34:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkkCAI4qw0nRVdulmGdsb2JhbACVJj8BAQEBAQgJDAcRrToHgQCPKwEDAQODegaDTIFT X-IronPort-AV: E=Sophos;i="4.38,395,1233529200"; d="scan'208";a="25963588" Received: from mail-ew0-f165.google.com ([209.85.219.165]) by mail1-smtp-roc.national.inria.fr with ESMTP; 20 Mar 2009 13:34:45 +0100 Received: by mail-ew0-f165.google.com with SMTP id 9so665383ewy.9 for ; Fri, 20 Mar 2009 05:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=kxE179xOu7bcaEJ1GMaR3XMoaGAlviXXSwLo23cV3e0=; b=Zei9e5XtI/UkyCvEc/HmuOILmZoY2PpHdh8rIPCJtpgkuoO45usdSucNXM073jJS8F haBEYcD/fwQ987/4w91lXgrgo3mqWDf2msvJNOEFKbTfztN+b+Na1rzZKZRrQ0RTAR4r /U613+y/w2G+fcRq7HtodYwnz5C5hBuEKJtDs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=ZA0nwU+9nRIneko/YHycgxlxJbdMFMEpZq/581od9lZ/wMLNSRFhgVdcXz7QW6nqXI Ae763xX4mHGMJu8rK/1/hIJV/AF0TGTTI8S3hmoXRpnzGJnS2W4J0aJ8trYBe6DPXR0l ikR/BYBnyjdnGFTYdukAdjKQFqIedoKDxfktA= Received: by 10.216.22.78 with SMTP id s56mr1732337wes.100.1237552485650; Fri, 20 Mar 2009 05:34:45 -0700 (PDT) Received: from ?192.168.0.102? (papillon.metalscan.fr [212.73.210.234]) by mx.google.com with ESMTPS id 7sm2162114eyb.30.2009.03.20.05.34.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 20 Mar 2009 05:34:45 -0700 (PDT) Message-ID: <49C38D64.1000200@gmail.com> Date: Fri, 20 Mar 2009 13:34:44 +0100 From: Matthieu Dubuget Reply-To: matthieu.dubuget@gmail.com User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: caml-list@inria.fr Subject: ocamlc linking with .dll Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; matthieu:01 dubuget:01 matthieu:01 dubuget:01 ocamlc:01 ocamlc:01 bytecode:01 run-time:01 ocamlrun:01 -custom:01 stub:01 stub:01 runtime:01 -verbose:01 -custom:01 According to the manual, for ocamlc: > Arguments ending in .so (.dll under Windows) are assumed to be C > shared libraries (DLLs). > During linking, they are searched for external C functions referenced > from the Caml code, > and their names are written in the generated bytecode executable. The > run-time system > ocamlrun then loads them dynamically at program start-up time. If I try: > $ ocamlc -custom -o m.exe ms_gates.native.dll m_stub.c m.ml > ** Cannot resolve symbols for m_stub.o: > _ms_gates_init > _ms_gates_version > File "m.ml", line 1, characters 0-1: > Error: Error while building custom runtime system The dll is not passed to flexlink, as we can check with "-verbose": > $ ocamlc -custom -o m.exe -verbose ms_gates.native.dll > m_stub.c m.ml > + gcc -mno-cygwin -O -mms-bitfields -Wall -Wno-unused -c > -I"C:/cygwin/home/matt/ocamlmgw/lib" "m_stub.c" > + flexlink -chain mingw -exe -o "m.exe" > "-LC:/cygwin/home/matt/ocamlmgw/lib" > "c:\DOCUME~1\matt\LOCALS~1\Temp\camlprimec3406.c" "m_stub.o" > "-lcamlrun" -lws2_32 > ** Cannot resolve symbols for m_stub.o: > _ms_gates_init > _ms_gates_version > File "m.ml", line 1, characters 0-1: > Error: Error while building custom runtime system This is solved by adding -cclib in front of the dll name: > $ ocamlc -custom -o m.exe -verbose -cclib ms_gates.native.dll > m_stub.c m.ml > + gcc -mno-cygwin -O -mms-bitfields -Wall -Wno-unused -c > -I"C:/cygwin/home/matt/ocamlmgw/lib" "m_stub.c" > > + flexlink -chain mingw -exe -o "m.exe" > "-LC:/cygwin/home/matt/ocamlmgw/lib" > "c:\DOCUME~1\matt\LOCALS~1\Temp\camlprimc0b326.c" > "ms_gates.native.dll" "m_stub.o" "-lcamlrun" -lws2_32 > Is there a bug, either in the documentation or in ocamlc? Salutations Matt