On Fri, May 09, 2014, Leonardo Laguna wrote:
> This is what I'm executing:My take on it (as you can see, it's really mine) would be something
>
> 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"
like (with an ocaml toolchain based on the mingw port):
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