caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] creating a standalone labltk program
@ 2011-07-28 12:43 ben mailist
  2011-07-30 10:35 ` ygrek
  2011-07-30 14:20 ` Jacques Garrigue
  0 siblings, 2 replies; 3+ messages in thread
From: ben mailist @ 2011-07-28 12:43 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 840 bytes --]

hi

I try to staticall link all necessary libraries to create a standalone
labltk application. So that it is no longer necessary to install the tcl/tk
runtime on the target machine.

Environment:
  - mac os x 10.6
  - ocaml 3.12.1

Build command:

    $ ocamlopt -o lb -linkall  -I +labltk labltk.cmxa listbox01.ml

Size looks promising:

    $ du -sh lb
     2.6 M

But its not running. After disabling the Tk.framework directory, I get this

Error:

    $ ./lb
dyld: Library not loaded:
/System/Library/Frameworks/Tk.framework/Versions/8.5/Tk
  Referenced from: /Volumes/.../temp/./lb
  Reason: image not found
Trace/BPT trap

Apparently the '-linkall' switch is not enough. Is this something that has
to be defined with ./configure when compiling ocaml? I couldn't find an
appropriate ./configure switch for that.

thanks in advance
ben

[-- Attachment #2: Type: text/html, Size: 1254 bytes --]

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

* Re: [Caml-list] creating a standalone labltk program
  2011-07-28 12:43 [Caml-list] creating a standalone labltk program ben mailist
@ 2011-07-30 10:35 ` ygrek
  2011-07-30 14:20 ` Jacques Garrigue
  1 sibling, 0 replies; 3+ messages in thread
From: ygrek @ 2011-07-30 10:35 UTC (permalink / raw)
  To: ben mailist; +Cc: caml-list

On Thu, 28 Jul 2011 14:43:58 +0200
ben mailist <ben.mailist@gmail.com> wrote:

> I try to staticall link all necessary libraries to create a standalone
> labltk application. So that it is no longer necessary to install the tcl/tk
> runtime on the target machine.
> [...]
>     $ ocamlopt -o lb -linkall  -I +labltk labltk.cmxa listbox01.ml

-linkall links in all ocaml modules, it has nothing to do with linking of external libraries.
In order to link everything statically you need to ask C linker to do so - the simplest way is
to use `-ccopt -static` but that means linking in libc which is not good usually. More involved and 
correct way is to wrap all external libraries with `-Wl,-Bstatic -lxxx -Wl,-Bdynamic` on command-line.
Note that using `ocamlopt -ccopt -Wl,-Bstatic <all arguments> -ccopt -Wl,-Bdynamic` (to wrap all libs
at once) will not usually work as ocamlopt reorders `-ccopt` at will :( Use `-verbose` to check what is
being passed to gcc.

-- 
 ygrek
 http://ygrek.org.ua

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

* Re: [Caml-list] creating a standalone labltk program
  2011-07-28 12:43 [Caml-list] creating a standalone labltk program ben mailist
  2011-07-30 10:35 ` ygrek
@ 2011-07-30 14:20 ` Jacques Garrigue
  1 sibling, 0 replies; 3+ messages in thread
From: Jacques Garrigue @ 2011-07-30 14:20 UTC (permalink / raw)
  To: ben mailist; +Cc: caml-list

On 2011/07/28, at 21:43, ben mailist wrote:

> hi
> 
> I try to staticall link all necessary libraries to create a standalone labltk application. So that it is no longer necessary to install the tcl/tk runtime on the target machine.

Unfortunately, this is more or less impossible to achieve: Tcl/Tk requires its own library of tcl scripts to be installed on the target machine, so that you cannot be really standalone. By either using ocamlopt or ocamlc -custom, you limit the dependency to having the right version of Tcl/Tk installed, which should not be too hard on  Unix/OSX or for a motivated windows user.
The situation is a bit better with lablgtk: you can create standalone executables (see unison for instance for how to do that).
You loose part of the functionality of gtk (themes and input methods require dynamic loading), but your application will still work.

Jacques Garrigue

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

end of thread, other threads:[~2011-07-30 14:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 12:43 [Caml-list] creating a standalone labltk program ben mailist
2011-07-30 10:35 ` ygrek
2011-07-30 14:20 ` Jacques Garrigue

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).