* [Caml-list] Self contained Windows executable? @ 2014-05-19 7:42 Andre Tampubolon 2014-05-19 7:55 ` David Allsopp ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Andre Tampubolon @ 2014-05-19 7:42 UTC (permalink / raw) To: caml-list [-- Attachment #1: Type: text/plain, Size: 518 bytes --] Hello folks, I just built ocaml on Windows 7 (mingw). I notice that executables compiled with ocamlc (e.g ocamlc hello.ml -o hello.exe) won't run on another machine. It says "Cannot exec ocamlrun". It seems that executables created with ocaml are not "native" executables, because ocamlrun is still needed. On the other hand, executables compiled with ocamlopt require Cygwin DLLs. Is there any workaround? -- *Andre Tampubolon* GPG public key:http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC6492E7D01AA96CF [-- Attachment #2: Type: text/html, Size: 1181 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [Caml-list] Self contained Windows executable? 2014-05-19 7:42 [Caml-list] Self contained Windows executable? Andre Tampubolon @ 2014-05-19 7:55 ` David Allsopp 2014-05-19 7:56 ` Adrien Nader [not found] ` <E51C5B015DBD1348A1D85763337FB6D9E8EEFDA5@Remus.metastack.local> 2 siblings, 0 replies; 6+ messages in thread From: David Allsopp @ 2014-05-19 7:55 UTC (permalink / raw) To: caml-list [-- Attachment #1: Type: text/plain, Size: 1190 bytes --] ocamlopt-compiled native executables do not require Cygwin DLLs on Windows, unless you accidentally built the Cygwin port (by running configure) rather than the MinGW port (by following the instruction to edit config/ files in README.win32). It is normal that ocamlc-compiled executables require ocamlrun (they do on *nix as well) unless you compile with -custom (which embeds the runtime system in the executable). David From: caml-list-request@inria.fr [mailto:caml-list-request@inria.fr] On Behalf Of Andre Tampubolon Sent: 19 May 2014 08:43 To: caml-list@yquem.inria.fr Subject: [Caml-list] Self contained Windows executable? Hello folks, I just built ocaml on Windows 7 (mingw). I notice that executables compiled with ocamlc (e.g ocamlc hello.ml<http://hello.ml> -o hello.exe) won't run on another machine. It says "Cannot exec ocamlrun". It seems that executables created with ocaml are not "native" executables, because ocamlrun is still needed. On the other hand, executables compiled with ocamlopt require Cygwin DLLs. Is there any workaround? -- Andre Tampubolon GPG public key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC6492E7D01AA96CF [-- Attachment #2: Type: text/html, Size: 5239 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Self contained Windows executable? 2014-05-19 7:42 [Caml-list] Self contained Windows executable? Andre Tampubolon 2014-05-19 7:55 ` David Allsopp @ 2014-05-19 7:56 ` Adrien Nader [not found] ` <E51C5B015DBD1348A1D85763337FB6D9E8EEFDA5@Remus.metastack.local> 2 siblings, 0 replies; 6+ messages in thread From: Adrien Nader @ 2014-05-19 7:56 UTC (permalink / raw) To: Andre Tampubolon; +Cc: caml-list Hi, On Mon, May 19, 2014, Andre Tampubolon wrote: > Hello folks, > > I just built ocaml on Windows 7 (mingw). > I notice that executables compiled with ocamlc (e.g ocamlc hello.ml -o > hello.exe) won't run on another machine. It says "Cannot exec ocamlrun". > > It seems that executables created with ocaml are not "native" executables, > because ocamlrun is still needed. On the other hand, executables compiled > with ocamlopt require Cygwin DLLs. > > Is there any workaround? Yes, ocamlc's output requires ocamlrun to execute since it's only bytecode and is portable (modulo C bindings). You need to use ocamlopt instead of ocamlc, it will generate native executables which are not portable. That ocamlopt's output requires cygwin1.dll means you've run the cygwin OCaml compiler; it depends on what you've installed and there are binaries of non-cygwin ocaml compilers available on http://caml.inria.fr (there might also be a cygwin package with one but it's probably a bit old) -- Adrien nader ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <E51C5B015DBD1348A1D85763337FB6D9E8EEFDA5@Remus.metastack.local>]
[parent not found: <CAOEA5rZWJ+HfwkCGnLPbwwz7GVHZ6R7_ioZfyabFyNOuNnPhrg@mail.gmail.com>]
* RE: [Caml-list] Self contained Windows executable? [not found] ` <CAOEA5rZWJ+HfwkCGnLPbwwz7GVHZ6R7_ioZfyabFyNOuNnPhrg@mail.gmail.com> @ 2014-05-19 9:10 ` David Allsopp 2014-05-19 9:22 ` Jonathan Protzenko 0 siblings, 1 reply; 6+ messages in thread From: David Allsopp @ 2014-05-19 9:10 UTC (permalink / raw) To: OCaml List (caml-list@yquem.inria.fr) Andre Tampubolon wrote: > Hi David, > I think I built ocaml correctly using MinGW, as stated in README.win32 > cp config/m-nt.h config/m.h > cp config/s-nt.h config/s.h > cp config/Makefile.msvc config/Makefile > Followed by: > make -f Makefile.nt world > make -f Makefile.nt bootstrap > make -f Makefile.nt opt > make -f Makefile.nt opt.opt > make -f Makefile.nt install Yes, that is the correct procedure! > If ocamlopt is invoked outside Cygwin Bash Shell, it will give this error: > C:\Users\CSL-NB-064\Codes\OCaml>ocamlopt cholesky.ml -o cholesky.exe > 'i686-w64-mingw32-as' is not recognized as an internal or external command, > operable program or batch file. > File "cholesky.ml", line 1: > Error: Assembler error, input left in file C:\Users\CSL-NB~1\AppData\Local\Temp\camlasmfac3bb.s If running from cmd, you need to put Cygwin's bin dir into your PATH (you can do this by symlinking the required executables from your OCaml installation's bin directory, but it's non-trivial - I can give you the details if you're really interested) > Of course ocamlopt works fine in Cygwin. The executables compiled with it need Cygwin DLLs , though. "Of course" doesn't make sense here! If you do have a Cygwin installation of OCaml knocking around, that will certainly confuse things. Ways to tell: On my system: $ which ocaml /cygdrive/c/Dev/OCaml/bin/ocaml (i.e. the path should be where you've installed MinGW OCaml and not /usr/bin/ocaml of something similar) $ ocamlopt -config | fgrep native_c native_c_compiler: i686-w64-mingw32-gcc -O -mms-bitfields -Wall -Wno-unused native_c_libraries: -lws2_32 (i.e. the compiler should be i686-w64-mingw32-gcc rather than plain gcc which is what the Cygwin port uses) Neither the executables produced by ocamlopt, nor the OCaml tools themselves (ocamlc.exe, ocamlopt.exe, etc.) should depend on Cygwin DLLs for either the MinGW or MSVC ports. David ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Self contained Windows executable? 2014-05-19 9:10 ` David Allsopp @ 2014-05-19 9:22 ` Jonathan Protzenko 2014-05-19 9:28 ` Adrien Nader 0 siblings, 1 reply; 6+ messages in thread From: Jonathan Protzenko @ 2014-05-19 9:22 UTC (permalink / raw) To: caml-list Shameless plug: there's a blog post at gagallium's which recaps the various versions of OCaml on windows <http://gallium.inria.fr/~scherer/gagallium/the-ocaml-installer-for-windows/>. tl;dr : - the "ocaml" package from the cygwin distribution is a cygwin program which generates cygwin executables -- these depend on cygwin1.dll to run - the installer from http://protz.github.com/ocaml-installer/ is a native windows program, which generates native windows program -- these do not need anything specific to execute. The second option does also require cygwin, however, as most of the ecosystem (e.g. ocamlbuild) assumes a unix-like environment. Cheers, ~ jonathan On Mon 19 May 2014 11:10:48 AM CEST, David Allsopp wrote: > Andre Tampubolon wrote: >> Hi David, >> I think I built ocaml correctly using MinGW, as stated in README.win32 >> cp config/m-nt.h config/m.h >> cp config/s-nt.h config/s.h >> cp config/Makefile.msvc config/Makefile >> Followed by: >> make -f Makefile.nt world >> make -f Makefile.nt bootstrap >> make -f Makefile.nt opt >> make -f Makefile.nt opt.opt >> make -f Makefile.nt install > > Yes, that is the correct procedure! > >> If ocamlopt is invoked outside Cygwin Bash Shell, it will give this error: >> C:\Users\CSL-NB-064\Codes\OCaml>ocamlopt cholesky.ml -o cholesky.exe >> 'i686-w64-mingw32-as' is not recognized as an internal or external command, >> operable program or batch file. >> File "cholesky.ml", line 1: >> Error: Assembler error, input left in file C:\Users\CSL-NB~1\AppData\Local\Temp\camlasmfac3bb.s > > If running from cmd, you need to put Cygwin's bin dir into your PATH (you can do this by symlinking the required executables from your OCaml installation's bin directory, but it's non-trivial - I can give you the details if you're really interested) > >> Of course ocamlopt works fine in Cygwin. The executables compiled with it need Cygwin DLLs , though. > > "Of course" doesn't make sense here! If you do have a Cygwin installation of OCaml knocking around, that will certainly confuse things. Ways to tell: > > On my system: > > $ which ocaml > /cygdrive/c/Dev/OCaml/bin/ocaml > > (i.e. the path should be where you've installed MinGW OCaml and not /usr/bin/ocaml of something similar) > > $ ocamlopt -config | fgrep native_c > native_c_compiler: i686-w64-mingw32-gcc -O -mms-bitfields -Wall -Wno-unused > native_c_libraries: -lws2_32 > > (i.e. the compiler should be i686-w64-mingw32-gcc rather than plain gcc which is what the Cygwin port uses) > > Neither the executables produced by ocamlopt, nor the OCaml tools themselves (ocamlc.exe, ocamlopt.exe, etc.) should depend on Cygwin DLLs for either the MinGW or MSVC ports. > > > David > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Self contained Windows executable? 2014-05-19 9:22 ` Jonathan Protzenko @ 2014-05-19 9:28 ` Adrien Nader 0 siblings, 0 replies; 6+ messages in thread From: Adrien Nader @ 2014-05-19 9:28 UTC (permalink / raw) To: Jonathan Protzenko; +Cc: caml-list On Mon, May 19, 2014, Jonathan Protzenko wrote: > Shameless plug: there's a blog post at gagallium's which recaps the > various versions of OCaml on windows > <http://gallium.inria.fr/~scherer/gagallium/the-ocaml-installer-for-windows/>. > > tl;dr : > - the "ocaml" package from the cygwin distribution is a cygwin program > which generates cygwin executables -- these depend on cygwin1.dll to run > - the installer from http://protz.github.com/ocaml-installer/ is a > native windows program, which generates native windows program -- these > do not need anything specific to execute. And it works well. :) (although I had to do a couple weird things to have it really integrate with win-builds) > The second option does also require cygwin, however, as most of the > ecosystem (e.g. ocamlbuild) assumes a unix-like environment. Nitpick: ocamlbuild doesn't really assume a unix-like environment. It implements 'cp' through 'system("cp...")' (fixable) and runs user-defined commands through Sys.command too which is cmd.exe on Windows and has completely different escaping rules and therefore wraps them first inside a call to an sh.exe. Unfortunately that last point will require breaking compat to fix well (commands would be provided as a string array à la Unix.create_process, not as a string). -- Adrien Nader ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-19 9:28 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-05-19 7:42 [Caml-list] Self contained Windows executable? Andre Tampubolon 2014-05-19 7:55 ` David Allsopp 2014-05-19 7:56 ` Adrien Nader [not found] ` <E51C5B015DBD1348A1D85763337FB6D9E8EEFDA5@Remus.metastack.local> [not found] ` <CAOEA5rZWJ+HfwkCGnLPbwwz7GVHZ6R7_ioZfyabFyNOuNnPhrg@mail.gmail.com> 2014-05-19 9:10 ` David Allsopp 2014-05-19 9:22 ` Jonathan Protzenko 2014-05-19 9:28 ` Adrien Nader
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox