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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 122787EE80 for ; Mon, 25 Mar 2013 03:23:21 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of romain.beauxis@gmail.com) identity=pra; client-ip=209.85.215.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="romain.beauxis@gmail.com"; x-sender="romain.beauxis@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of romain.beauxis@gmail.com designates 209.85.215.42 as permitted sender) identity=mailfrom; client-ip=209.85.215.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="romain.beauxis@gmail.com"; x-sender="romain.beauxis@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-la0-f42.google.com) identity=helo; client-ip=209.85.215.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="romain.beauxis@gmail.com"; x-sender="postmaster@mail-la0-f42.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgsCALizT1HRVdcqgmdsb2JhbABDx1EIFg4BAQsJFBIGJIIlAQVAATgBAwwBBQULOyISAQUBHAYTiAIDDwykHY8thAEnDYlVAQEEDJJTA5ZnjyIWKYFZglU7 X-IPAS-Result: AgsCALizT1HRVdcqgmdsb2JhbABDx1EIFg4BAQsJFBIGJIIlAQVAATgBAwwBBQULOyISAQUBHAYTiAIDDwykHY8thAEnDYlVAQEEDJJTA5ZnjyIWKYFZglU7 X-IronPort-AV: E=Sophos;i="4.84,902,1355094000"; d="scan'208";a="7660497" Received: from mail-la0-f42.google.com ([209.85.215.42]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 25 Mar 2013 03:23:20 +0100 Received: by mail-la0-f42.google.com with SMTP id fe20so10464545lab.29 for ; Sun, 24 Mar 2013 19:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=HfMiOBm5X0F1LzeXCqUnONLcMzio9ACsq/BvEVm/9dI=; b=BzlRnjFZOMj1+pwqskL30QjJgyX11PRD5KanHmw71lNxhSPsZ3zv50DAJ8DI9RYJUU ZarkUyEtEgzW8hRf49hXmUDfEd33gJTyH0B3NoAw03wRqlr3tlv3GYHyonz1JgcTsX4D EYBmGTYW1iidRdx6FwGyXOz6W9N9ygB+1PKlnIA7lE2bbN966jCf4dejkGCHJ5OpszIS +U8LONUV++hX9O+vQQUeLMThRMna9bWYIMHK4wesYE70efBWIw4sDK5uTTykLzObVsNx 4y1kNosODW+wnQuhdYqoojugv0QRK58txgpcZGLaXAqoDcK6GK5F2ZUuOMewU1jkt7sd 4y7w== X-Received: by 10.112.18.168 with SMTP id x8mr5108491lbd.102.1364178199352; Sun, 24 Mar 2013 19:23:19 -0700 (PDT) MIME-Version: 1.0 Sender: romain.beauxis@gmail.com Received: by 10.112.73.233 with HTTP; Sun, 24 Mar 2013 19:22:59 -0700 (PDT) In-Reply-To: References: From: Romain Beauxis Date: Mon, 25 Mar 2013 03:22:59 +0100 X-Google-Sender-Auth: Uo3-eP9jVuVrVFlmyX6wkkf6cZo Message-ID: To: OCaml List Cc: Samuel Mimram Content-Type: text/plain; charset=ISO-8859-1 X-Validation-by: romain.beauxis@gmail.com Subject: [Caml-list] Re: Mingw-ocaml and C++ 2013/3/24 Romain Beauxis : > Hi all, > > I have extracted the debian-specific build for mingw-ocaml into a > standalone build: > https://github.com/savonet/mingw-ocaml > > You should be able to use it to build mingw-ocaml for windows 32 and > 64 bit. It has been updated with the latest ocaml (4.00.1) and flexdll > (0.30) > > However, I am having some serious trouble with C++ FlexDLL linking on > Debian wheezy and sid. > > This is a problem that occurs when building OCaml modules based on C++ > libraries. Here's a simple way to reproduce. It does not involve OCaml > but showcases the exact issue I am having with libraries and is damn > simple: > > - Install mingw-ocaml or compile it from the sources above. Doesn't > matter the version, bug is the same. > > - Create this file: > > % cat hello.cpp > #include > > int main() > { > std::cout << "Hello World!" << std::endl; > return 0; > } > > - Compile it: > > % i686-w64-mingw32-g++ -c hello.cpp > > - Link it with gcc: > % i686-w64-mingw32-gcc -o hello.exe ./hello.o -lstdc++ > > - Try to link it with flexlink: > > % flexlink -exe -chain mingw -L/usr/i686-w64-mingw32/lib -o > hello-flexlink.exe -lstdc++ hello.o -v -v -v > ** Use cygpath: false > ** Search path: > /usr/i686-w64-mingw32/lib > /usr/lib/gcc/i686-w64-mingw32/4.6 > /mingw/lib > ** Default libraries: > crt2.o > -lmingw32 > -lgcc > -lmoldname > -lmingwex > -lmsvcrt > -luser32 > -lkernel32 > -ladvapi32 > -lshell32 > ** Cannot resolve symbols for hello.o: > __ZSt4cout > ** open: /usr/i686-w64-mingw32/lib/crt2.o > ** open: /usr/i686-w64-mingw32/lib/libmingw32.a > ** open: /usr/lib/gcc/i686-w64-mingw32/4.6/libgcc.a > ** open: /usr/i686-w64-mingw32/lib/libmoldname.a > ** open: /usr/i686-w64-mingw32/lib/libmingwex.a > ** open: /usr/i686-w64-mingw32/lib/libmsvcrt.a > ** open: /usr/i686-w64-mingw32/lib/libuser32.a > ** open: /usr/i686-w64-mingw32/lib/libkernel32.a > ** open: /usr/i686-w64-mingw32/lib/libadvapi32.a > ** open: /usr/i686-w64-mingw32/lib/libshell32.a > zsh: exit 2 flexlink -exe -chain mingw -L/usr/i686-w64-mingw32/lib > -o hello.exe -lstdc++ I have been able to build a working binary by adding manually the stdc++ DLL: % flexlink -exe -chain mingw -L/usr/i686-w64-mingw32/lib -o hello-flexlink.exe /usr/lib/gcc/i686-w64-mingw32/4.6/libstdc++-6.dll hello.o This produces a working hello-flexlink.exe binary. with OCaml modules using C++ bindings, I've had to also add -noreexport and to sometimes also add gcc_s_sjlj DLL. It seems to me that flexlink does not seem to be fit for using C++ symbols or that it should restrict some of its magic when dealing with C++ symbols but alas I have no idea how to properly patch it for that purpose. Romain