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 <adrien@notk.org> wrote:
Hi,

On Fri, May 09, 2014, Leonardo Laguna wrote:
> Hello,
>
> I’m 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 ‘Interoperability with C’ of
> the book ‘Developing applications with Objective Caml’) and works fine.
> However in windows I’m 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 MinGW
> port. For that reason I tried to compile the MSVC port of Ocaml and I didn’t
> 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 ‘link’, so I downloaded the flexlink code
> and changed it to call instead ‘link.exe’, this worked. Then flexlink could
> not handle Cygwin paths like ‘/tmp/’or ‘/cygdrive/c/’ . I modified the code so
> it replaces the Cygwin paths to Windows paths. It worked. I continued until I
> got the message that the ‘ml’ command does not exist. The environment is set
> correctly and I can call ‘ml’ 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