caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Romain Beauxis <toots@rastageeks.org>
To: OCaml List <caml-list@inria.fr>
Cc: Samuel Mimram <smimram@gmail.com>
Subject: [Caml-list] Re: Mingw-ocaml and C++
Date: Mon, 25 Mar 2013 03:22:59 +0100	[thread overview]
Message-ID: <CABWZ6OR3CTdqUs4xgszwMZTcrrnZuHm7nubazh+iTmPA7ZC2xQ@mail.gmail.com> (raw)
In-Reply-To: <CABWZ6OSFym5vwgcKvF19rtyq3zPXfAoSwYjpvhO+Kfw_fx0s-Q@mail.gmail.com>

2013/3/24 Romain Beauxis <toots@rastageeks.org>:
> 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 <iostream>
>
> 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

      reply	other threads:[~2013-03-25  2:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-24 11:43 [Caml-list] " Romain Beauxis
2013-03-25  2:22 ` Romain Beauxis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABWZ6OR3CTdqUs4xgszwMZTcrrnZuHm7nubazh+iTmPA7ZC2xQ@mail.gmail.com \
    --to=toots@rastageeks.org \
    --cc=caml-list@inria.fr \
    --cc=smimram@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).