2

How can one create or compile a GUI application under Windows without a console? I have already searched the Internet, but I didn't find anything useful. I would appreciate any guidance you can provide.

(* ocamlc -I +labltk labltk.cma gui.ml -o gui.exe *)

open Tk ;;

let top = openTk () ;;
Wm.title_set top "Application 1" ;;
Wm.geometry_set top "200x500";;

let blue = Button.create ~text:"Blue" top ;;
let red = Button.create ~text:"Red" top ;;
pack [blue ; red];;

let mylist = Listbox.create ~selectmode:`Multiple top
let _ = Listbox.insert
    ~index:`End
    ~texts:["Mozart";"Chopin";"Beethoven";"Verdi";"Bizet"]
    mylist ;;
pack [mylist];;

let _ = Printexc.print mainLoop ();;
Thomash
  • 6,339
  • 1
  • 30
  • 50
SkoAleVal
  • 23
  • 2

2 Answers2

4

you need to pass '-subsystem windows' to the linker; and probably '-custom', because ocamlrun.exe is a console application:

ocamlc -I +labltk labltk.cma gui.ml -custom -cclib -subsystem -cclib windows -o gui.exe
rafix
  • 1,739
  • 9
  • 9
  • cygwin warning: MS-DOS style path detected: C:\DOCUME~1\SA\LOCALS~1\Temp\camlprim8e3098.c Preferred POSIX equivalent is: /cygdrive/c/DOCUME~1/SA/LOCALS~1/Temp/camlprim8 e3098.c CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames ** Fatal error: Cannot find file "libws2_32" File "gui.ml", line 1: Error: Error while building custom runtime system – SkoAleVal Sep 21 '13 at 17:38
2

I'm mostly an OS X / Unix / Linux programmer myself, but you might try this other SO page:

Hide console of Windows Application

The key factors appear to be linker options and the entry point name.

Community
  • 1
  • 1
Jeffrey Scofield
  • 65,646
  • 2
  • 72
  • 108