From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 5BB6C7ED9B for ; Fri, 9 May 2014 23:54:22 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of adrien@notk.org) identity=pra; client-ip=91.121.71.147; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="adrien@notk.org"; x-sender="adrien@notk.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of adrien@notk.org designates 91.121.71.147 as permitted sender) identity=mailfrom; client-ip=91.121.71.147; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="adrien@notk.org"; x-sender="adrien@notk.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@nautica.notk.org) identity=helo; client-ip=91.121.71.147; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="adrien@notk.org"; x-sender="postmaster@nautica.notk.org"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhIFAD1ObVNbeUeT/2dsb2JhbABZgwZPgz/CbAGBGhZ0giUBAQUjVhALDgoCAgUTDgICDwUYMYhYrE+kSheBKo0oB4J1NoEVBJlGAYE8kUaDODs X-IPAS-Result: AhIFAD1ObVNbeUeT/2dsb2JhbABZgwZPgz/CbAGBGhZ0giUBAQUjVhALDgoCAgUTDgICDwUYMYhYrE+kSheBKo0oB4J1NoEVBJlGAYE8kUaDODs X-IronPort-AV: E=Sophos;i="4.97,1020,1389740400"; d="scan'208";a="72914041" Received: from nautica.notk.org ([91.121.71.147]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 09 May 2014 23:54:22 +0200 Received: by nautica.notk.org (Postfix, from userid 1003) id 08E4BC009; Fri, 9 May 2014 23:54:21 +0200 (CEST) Date: Fri, 9 May 2014 23:54:21 +0200 From: Adrien Nader To: Leonardo Laguna Cc: caml-list@inria.fr Message-ID: <20140509215421.GA26545@notk.org> References: <20140509121324.GA26367@notk.org> <20140509202046.GA17828@notk.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] Embedding Ocaml in a windows application On Fri, May 09, 2014, Leonardo Laguna wrote: > This is what I'm executing: > > ocamlopt -output-obj -o ocamllibrary.o library.ml > cl /c my_plugin.c /I"C:\\wodi32\\opt\\wodi32\\lib\\ocaml\\std-lib" > cl /c ocaml_stub.c /I"C:\\wodi32\\opt\\wodi32\\lib\\ocaml\\std-lib" > flexlink -chain msvc -exe -o my_plugin.exe my_plugin.obj ocaml_stub.obj > ocamllibrary.o plug.lib -lasmrun -lgcc -L > "C:\wodi32\lib\gcc\i686-w64-mingw32\4.8.2" My take on it (as you can see, it's really mine) would be something like (with an ocaml toolchain based on the mingw port): ocamlopt -output-obj -o ocamllibrary.o library.ml ocamlc -c my_plugin.c ocamlc -c ocaml_stub.c ocamlopt -o my_plugin.exe ocaml_stub.o my_plugin.o ocamllibrary.o plug.lib The ideas behind this are: - gcc and msvc create compatible object files even though they have a different extension - static libraries are archives of objects and are also usable directly - the ocaml compiler knows best how to call the C compiler for C files; calling the C compiler by hand is an endless source of pain (if you want more details, add -verbose to the ocaml* invocations) - same for the linker -- Adrien Nader