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 6E7877ED9B for ; Fri, 9 May 2014 22:16:05 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of modlfo@gmail.com) identity=pra; client-ip=209.85.216.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="modlfo@gmail.com"; x-sender="modlfo@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of modlfo@gmail.com designates 209.85.216.180 as permitted sender) identity=mailfrom; client-ip=209.85.216.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="modlfo@gmail.com"; x-sender="modlfo@gmail.com"; 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@mail-qc0-f180.google.com) identity=helo; client-ip=209.85.216.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="modlfo@gmail.com"; x-sender="postmaster@mail-qc0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkACAJc2bVPRVdi0lGdsb2JhbABZg1VYgmeoTgEGgmWXMwGBEggWDgEBAQEHCwsJEiqCJQEBBAEjHQEbHQEDAQsGBQsNKgICIgERAQUBDgENBhOILAEDCQigUIwRUYMNmW8KGScNZIU7EQEFDIVKiHwHgnWBSwSVT4N4jSCDcRgphGg7 X-IPAS-Result: AkACAJc2bVPRVdi0lGdsb2JhbABZg1VYgmeoTgEGgmWXMwGBEggWDgEBAQEHCwsJEiqCJQEBBAEjHQEbHQEDAQsGBQsNKgICIgERAQUBDgENBhOILAEDCQigUIwRUYMNmW8KGScNZIU7EQEFDIVKiHwHgnWBSwSVT4N4jSCDcRgphGg7 X-IronPort-AV: E=Sophos;i="4.97,1020,1389740400"; d="scan'208";a="72907697" Received: from mail-qc0-f180.google.com ([209.85.216.180]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 May 2014 22:16:04 +0200 Received: by mail-qc0-f180.google.com with SMTP id i17so5210310qcy.39 for ; Fri, 09 May 2014 13:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=2ajdl1JO4duqTHJ6nbKSG+URXCqwf3wSmOtL7dLiYbI=; b=0T+NdHunk+UBp6HeZdzfYF8ezQsZb6QFbQz6f5swX7W8L88V6bHJwFLTnbrrNocPhs qOfMq9W4YpcJyKb9hM1hfdXU8DrOjWFMNh9sX28TbxC9v7F5D2PLJU+FsNvFOCNs96bm FbFCbtTeaHoecaRX19KZvgqvGMrwLSjyXG2x86T2/H4CBYnbppySBRN3OuFCblt6aRUt A70Zmv0N7dgtWgp5V9IXfM2Rh7yJ7TbSbOTUs2ktgwJb7NlnCkAmqXvVk6VPpuw6ejFM Q9+/Qyjo2QAhSA7N1Hfwq7CIZSNd9DpufH8lgz/uBfuZAehByjaEWRpRHlu5OdZOoOzq A6NQ== MIME-Version: 1.0 X-Received: by 10.224.54.68 with SMTP id p4mr17688136qag.47.1399666563368; Fri, 09 May 2014 13:16:03 -0700 (PDT) Received: by 10.224.123.14 with HTTP; Fri, 9 May 2014 13:16:03 -0700 (PDT) In-Reply-To: <20140509121324.GA26367@notk.org> References: <20140509121324.GA26367@notk.org> Date: Fri, 9 May 2014 22:16:03 +0200 Message-ID: From: Leonardo Laguna To: Adrien Nader Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=001a1132f70a5061e304f8fd442a Subject: Re: [Caml-list] Embedding Ocaml in a windows application --001a1132f70a5061e304f8fd442a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I have given up on compiling the msvc port. I don't know why I'm getting errors when the '.exe' is not there. I will try to explain better what I want to do. I have the following files: - plug.lib (provided by the software vendor, closed source, compiled with VC++), in OSX I have plug.a - my_main.c (the code for the plugin) - ocaml_stub.c (this code calls 'caml_startup()') - ocaml_code.ml in OSX I compile my_main.c, ocaml_stub.c and ocaml_code.ml to obtain '.o' files. Then I link the .o files with plug.a and libasmrun.a. This works fine. In windows I have wodi32, visual studio 2008 and Flexdll. I tried the following. - Using cl compile, ocaml_stub.c, my_main.c to obtain '.obj' files - Using ocamlopt, compile ocaml_code.ml to obtain a '.o' file - Using flexlink to link the .obj, .o, libasmrun.a, plug.lib, libgcc.a and libc.a This gives me an error: ** Cannot resolve symbols for libasmrun.a(floats.o): ___strtod I have tried to create my own strtod function and link it does not pick it. Anybody knows how can I link my program. Thanks. Leonardo On Fri, May 9, 2014 at 2:13 PM, Adrien Nader wrote: > Hi, > > On Fri, May 09, 2014, Leonardo Laguna wrote: > > Hello, > > > > I=E2=80=99m trying to make a plugin for a third party application using= Ocaml. > This > > plugin is a shared library that is usually written in C, so you take > your C > > code and link it with a static library (provided by the software vendor) > in > > order to get a shared library that can be loaded by the application. I > made a > > small test in OSX that embeds Ocaml (as shown in =E2=80=98Interoperabi= lity with > C=E2=80=99 of > > the book =E2=80=98Developing applications with Objective Caml=E2=80=99)= and works fine. > > However in windows I=E2=80=99m running into problems. > > > > The shared library that the vendor provides is compiler with VC++, > therefore > > is not possible to link object files produced by the Cygwin neither Min= GW > > port. For that reason I tried to compile the MSVC port of Ocaml and I > didn=E2=80=99t > > succeed. > > Depends: if the library is C then you can perfectly mix the two > compilers. Keep in mind that when you build with GCC on Windows, you're > still using the Windows libraries like msvcrt.dll or kernel32.dll and > they've been built using MSVC. > > > I followed the instructions in the README.win32. The first problem I had > was > > that flexlink was not able to call =E2=80=98link=E2=80=99, so I downloa= ded the flexlink > code > > and changed it to call instead =E2=80=98link.exe=E2=80=99, this worked.= Then flexlink > could > > not handle Cygwin paths like =E2=80=98/tmp/=E2=80=99or =E2=80=98/cygdri= ve/c/=E2=80=99 . I modified the > code so > > it replaces the Cygwin paths to Windows paths. It worked. I continued > until I > > got the message that the =E2=80=98ml=E2=80=99 command does not exist. T= he environment is > set > > correctly and I can call =E2=80=98ml=E2=80=99 from the terminal. > > > > Has anyone tried to compile the MSVC port lately? > > IIRC even the MSVC port is built from Cygwin and I think it won't mind > whether there are trailing '.exe' or not. > But now I'm not sure I understand: what is calling flexlink? Is it your > build system or the ocaml compiler's? > > -- > Adrien Nader > --001a1132f70a5061e304f8fd442a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I have given up on compiling the msvc port. I don't kn= ow why I'm getting errors when the '.exe' is not there.
I will try to explain better what I want to do.

I have the following files:

- plug.lib = (provided by the software vendor, closed source, compiled with VC++), in OS= X I have plug.a
- my_main.c (the code for the plugin)
- ocaml_stub.c (this code calls 'caml_startup()')

in O= SX I compile my_main.c, ocaml_stub.c and o= caml_code.ml to obtain '.o' files. Then I link the .o files wit= h plug.a and libasmrun.a. This works fine.

In windows I have wodi32, visual studio 2008 and Flexdl= l. I tried the following.
- Using cl compile, ocaml_stub.c, my_ma= in.c to obtain '.obj' files
- Using ocamlopt, compile ocaml_code.ml to obtain a '.o' fi= le
- Using flexlink to link the .obj, .o, libasmrun.a, plug.lib, libgcc.a= and libc.a

This gives me an error:

=
** Cannot resolve symbols for libasmrun.a(floats.o):
=C2=A0___strtod

I have tried to create = my own strtod function and link it does not pick it.

Anybody knows how can I link my program.

Thanks= .

Leonardo
=C2=A0=C2=A0




On Fri, May 9, 2014 at 2:13 PM, Adrien Nader <adrien@notk.org> wrote:
Hi,

On Fri, May 09, 2014, Leonardo Laguna wrote:
> Hello,
>
> I=E2=80=99m trying to make a plugin for a third party application usin= g Ocaml. =C2=A0This
> plugin is a shared library that is usually written in C, so you take y= our C
> code and link it with a static library (provided by the software vendo= r) in
> order to get a shared library that can be loaded by the application. = =C2=A0I made a
> small test in OSX that embeds Ocaml =C2=A0(as shown in =E2=80=98Intero= perability with C=E2=80=99 of
> the book =E2=80=98Developing applications with Objective Caml=E2=80=99= ) and works fine.
> However in windows I=E2=80=99m running into problems.
>
> The shared library that the vendor provides is compiler with VC++, the= refore
> is not possible to link object files produced by the Cygwin neither Mi= nGW
> port. For that reason I tried to compile the MSVC port of Ocaml and I = didn=E2=80=99t
> succeed.

Depends: if the library is C then you can perfectly mix the two
compilers. Keep in mind that when you build with GCC on Windows, you're=
still using the Windows libraries like msvcrt.dll or kernel32.dll and
they've been built using MSVC.

> I followed the instructions in the README.win32. The first problem I h= ad was
> that flexlink was not able to call =E2=80=98link=E2=80=99, so I downlo= aded the flexlink code
> and changed it to call instead =E2=80=98link.exe=E2=80=99, this worked= . Then flexlink could
> not handle Cygwin paths like =E2=80=98/tmp/=E2=80=99or =E2=80=98/cygdr= ive/c/=E2=80=99 . I modified the code so
> it replaces the Cygwin paths to Windows paths. It worked. I continued = until I
> got the message that the =E2=80=98ml=E2=80=99 command does not exist. = The environment is set
> correctly and I can call =E2=80=98ml=E2=80=99 from the terminal.
>
> Has anyone tried to compile the MSVC port lately?

IIRC even the MSVC port is built from Cygwin and I think it won't= mind
whether there are trailing '.exe' or not.
But now I'm not sure I understand: what is calling flexlink? Is it your=
build system or the ocaml compiler's?

--
Adrien Nader

--001a1132f70a5061e304f8fd442a--