caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ocamlopt, windows, and no console
@ 2006-04-10 15:19 Jonathan Roewen
  2006-04-10 17:21 ` Dmitry Bely
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Roewen @ 2006-04-10 15:19 UTC (permalink / raw)
  To: OCaml

Hi,

How does one generate an .exe using ocamlopt that doesn't launch a
console window?

Jonathan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] ocamlopt, windows, and no console
  2006-04-10 15:19 [Caml-list] ocamlopt, windows, and no console Jonathan Roewen
@ 2006-04-10 17:21 ` Dmitry Bely
  2006-04-10 17:41   ` Igor Peshansky
  2006-04-11  2:41   ` Jonathan Roewen
  0 siblings, 2 replies; 8+ messages in thread
From: Dmitry Bely @ 2006-04-10 17:21 UTC (permalink / raw)
  To: caml-list

"Jonathan Roewen" <jonathan.roewen@gmail.com> writes:

> How does one generate an .exe using ocamlopt that doesn't launch a
> console window?

What Ocaml build are you using? If Mingw one then I am afraid it's not
possible, but if it's MSVC-based I would try to play with

-cclib /link -cclib /subsystem:windows

options.

- Dmitry Bely


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] ocamlopt, windows, and no console
  2006-04-10 17:21 ` Dmitry Bely
@ 2006-04-10 17:41   ` Igor Peshansky
  2006-04-11  2:41   ` Jonathan Roewen
  1 sibling, 0 replies; 8+ messages in thread
From: Igor Peshansky @ 2006-04-10 17:41 UTC (permalink / raw)
  To: caml-list

On Mon, 10 Apr 2006, Dmitry Bely wrote:

> "Jonathan Roewen" writes:
>
> > How does one generate an .exe using ocamlopt that doesn't launch a
> > console window?
>
> What Ocaml build are you using? If Mingw one then I am afraid it's not
> possible, but if it's MSVC-based I would try to play with
>
> -cclib /link -cclib /subsystem:windows
>
> options.

In MinGW, you should be able to pass in the -mwindows flag to gcc (see
<http://www.mingw.org/docs.shtml>).
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha@cs.nyu.edu | igor@watson.ibm.com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] ocamlopt, windows, and no console
  2006-04-10 17:21 ` Dmitry Bely
  2006-04-10 17:41   ` Igor Peshansky
@ 2006-04-11  2:41   ` Jonathan Roewen
  2006-04-11  3:07     ` Jonathan Roewen
  2006-04-11 17:31     ` Harry Chomsky
  1 sibling, 2 replies; 8+ messages in thread
From: Jonathan Roewen @ 2006-04-11  2:41 UTC (permalink / raw)
  To: Dmitry Bely; +Cc: caml-list

> What Ocaml build are you using? If Mingw one then I am afraid it's not
> possible, but if it's MSVC-based I would try to play with
>
> -cclib /link -cclib /subsystem:windows
>
> options.

Indeed I was scanning the options, and found those. The problem is
that when you use that, you have to use WinMain instead...

C:\reflection>ocamlopt -cclib "/MD /link /SUBSYSTEM:WINDOWS" -o refl.exe -I +lab
lgl lablgl.cmxa lablglut.cmxa refl.ml
cl : Command line warning D4025 : overriding '/MT' with '/MD'
LIBCMT.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain@16
referenced in function _WinMainCRTStartup
refl.exe : fatal error LNK1120: 1 unresolved externals
Error during linking

I guess I'd have to provide a .c file which wraps ocaml's main
procedure then, which probably isn't too hard. Which then leads me to
requesting an option for the ocamlopt compiler for windows to have an
option to do this all automatically.

Jonathan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] ocamlopt, windows, and no console
  2006-04-11  2:41   ` Jonathan Roewen
@ 2006-04-11  3:07     ` Jonathan Roewen
  2006-04-11 14:33       ` David Allsopp
  2006-04-11 17:31     ` Harry Chomsky
  1 sibling, 1 reply; 8+ messages in thread
From: Jonathan Roewen @ 2006-04-11  3:07 UTC (permalink / raw)
  To: Dmitry Bely; +Cc: caml-list

> I guess I'd have to provide a .c file which wraps ocaml's main
> procedure then, which probably isn't too hard. Which then leads me to
> requesting an option for the ocamlopt compiler for windows to have an
> option to do this all automatically.

And back to the task at hand: how do I specify a .lib file on the
command line to get this all to link? I can't figure out the
cclib/ccopt options to pass to ocamlopt =/

Jonathan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [Caml-list] ocamlopt, windows, and no console
  2006-04-11  3:07     ` Jonathan Roewen
@ 2006-04-11 14:33       ` David Allsopp
  0 siblings, 0 replies; 8+ messages in thread
From: David Allsopp @ 2006-04-11 14:33 UTC (permalink / raw)
  To: caml-list

One other option is to change the startup mode of the executable after
compiling and linking it. I did this years ago with <cough> Visual Basic to
make true console applications (the reverse of your problem). I can't find
the code archive, but IIRC it involves changing a single byte in the PE
header that indicates the subsystem to use. The concept of main and winmain
come entirely from C - the actual entry point of your image is independent
of its subsystem so this gets around your linking problem.

I can't get at the machine with the archive of the tool I wrote for doing
this at the moment <sigh>. However, Microsoft have some utilities for doing
this although I don't know whether they will only work for programs
generated with their compiliers - google for Visual Basic's Link utility and
MSVC++'s editbin tool.

Hope this helps,


David

-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of Jonathan Roewen
Sent: 11 April 2006 04:08
To: Dmitry Bely
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] ocamlopt, windows, and no console

> I guess I'd have to provide a .c file which wraps ocaml's main
> procedure then, which probably isn't too hard. Which then leads me to
> requesting an option for the ocamlopt compiler for windows to have an
> option to do this all automatically.

And back to the task at hand: how do I specify a .lib file on the
command line to get this all to link? I can't figure out the
cclib/ccopt options to pass to ocamlopt =/

Jonathan

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] ocamlopt, windows, and no console
  2006-04-11  2:41   ` Jonathan Roewen
  2006-04-11  3:07     ` Jonathan Roewen
@ 2006-04-11 17:31     ` Harry Chomsky
  1 sibling, 0 replies; 8+ messages in thread
From: Harry Chomsky @ 2006-04-11 17:31 UTC (permalink / raw)
  To: Jonathan Roewen, Dmitry Bely; +Cc: caml-list

Jonathan Roewen wrote:
>> -cclib /link -cclib /subsystem:windows
>
> Indeed I was scanning the options, and found those. The problem is
> that when you use that, you have to use WinMain instead...

You can use the linker flag "/entry:mainCRTStartup" alongside the 
"/subsystem:windows" flag to achieve what you want: an executable with no 
console but using main() as the starting point.  That's what my OCaml-Win32 
library does when you link the tiny file lkwinapp.obj into your application. 
There's some discussion of the pros and cons of this approach in the 
build.txt file.  If you're curious, the library is available at:

http://www.speakeasy.org/~hchomsky/ocaml-win32.html


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] ocamlopt, windows, and no console
@ 2006-04-11 20:37 David Allsopp
  0 siblings, 0 replies; 8+ messages in thread
From: David Allsopp @ 2006-04-11 20:37 UTC (permalink / raw)
  To: caml-list

One other option is to change the startup mode of the executable after
compiling and linking it. I did this years ago with <cough> Visual Basic to
make true console applications (the reverse of your problem). I can't find
the code archive, but IIRC it involves changing a single byte in the PE
header that indicates the subsystem to use. The concept of main and winmain
come entirely from C - the actual entry point of your image is independent
of its subsystem so this gets around your linking problem.

I can't get at the machine with the archive of the tool I wrote for doing
this at the moment <sigh>. However, Microsoft have some utilities for doing
this although I don't know whether they will only work for programs
generated with their compiliers - google for Visual Basic's Link utility and
MSVC++'s editbin tool.

Hope this helps,


David

-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of Jonathan Roewen
Sent: 11 April 2006 04:08
To: Dmitry Bely
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] ocamlopt, windows, and no console

> I guess I'd have to provide a .c file which wraps ocaml's main
> procedure then, which probably isn't too hard. Which then leads me to
> requesting an option for the ocamlopt compiler for windows to have an
> option to do this all automatically.

And back to the task at hand: how do I specify a .lib file on the
command line to get this all to link? I can't figure out the
cclib/ccopt options to pass to ocamlopt =/

Jonathan

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-04-11 20:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-10 15:19 [Caml-list] ocamlopt, windows, and no console Jonathan Roewen
2006-04-10 17:21 ` Dmitry Bely
2006-04-10 17:41   ` Igor Peshansky
2006-04-11  2:41   ` Jonathan Roewen
2006-04-11  3:07     ` Jonathan Roewen
2006-04-11 14:33       ` David Allsopp
2006-04-11 17:31     ` Harry Chomsky
2006-04-11 20:37 David Allsopp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).