caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* dynamically finding libraries
@ 2007-03-15 13:42 Vu Ngoc San
       [not found] ` <1173969084.11071.16.camel@rosella.wigram>
  0 siblings, 1 reply; 3+ messages in thread
From: Vu Ngoc San @ 2007-03-15 13:42 UTC (permalink / raw)
  To: caml-list

I have a program compiled to native code on a linux machine, which uses 
some more-or-less "standard" library like libpangocairo-1.0.so.0.
Since this library is not universally present on all linux boxes, I 
suspect it might be not so easy for an average user to install it. 
Moreover, it's very small. Therefore I decide to ship it with my software.

The question is: is there a way to decide, at run-time, whether the user 
already has this library or not ? If so, I can ignore (and even delete) 
the version I shipped, and use the user's library. If not, I fall back 
on "my" version.


San


PS: sorry for the first message which appeared - at least with my news 
reader (icedove) - in the wrong thread.



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

* Re: [Caml-list] dynamically finding libraries
       [not found] ` <1173969084.11071.16.camel@rosella.wigram>
@ 2007-03-15 14:56   ` Vu Ngoc San
  0 siblings, 0 replies; 3+ messages in thread
From: Vu Ngoc San @ 2007-03-15 14:56 UTC (permalink / raw)
  To: skaller, Caml Mailing List

skaller a écrit :

> Of course there is a way to do this, but probably you shouldn't.
> Modern Linices usually have package managers, so you should
> just tell the client to install the library.
> 

I like packages, but I like as well the idea of a completely relocatable 
and distribution independent sotfware which could run, for instance, 
from a USB pen-drive.

I first tried to write a script setting LD_LIBRARY_PATH, but I have no 
idea about how to make it work with relative paths and allow symbolic links.

> Otherwise, you can write a C program that tries to call
> a function from the library, and compile, link, and run it,
> and check the result. This is a configuration time check.
> 
> For a run time check, you can call dlopen() and dlsym()
> on the library and a known symbol in the library.
> If you do this, however, you will have to access ALL the
> symbols in the library with dlsym (that is, indirectly).
> 

Darn. No ocaml trick for this ?

> Although Elf does allow load time lazy linkage of symbols,
> so missing symbols don't abort the program until they're
> used, there is no way I know of to have 'maybe' linkage
> of libraries. If your code is linked against a library
> the program will abort if it isn't found at run time,
> and before you get control.
> 
> The best you can do is try to figure out the error code,
> and restart the program in a script that adds 
> the directory containing your version in LD_LIBRARY_PATH.
> 


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

* dynamically finding libraries
  2007-03-14 22:25 Style and organization of code ian
@ 2007-03-15 13:38 ` Vu Ngoc San
  0 siblings, 0 replies; 3+ messages in thread
From: Vu Ngoc San @ 2007-03-15 13:38 UTC (permalink / raw)
  Cc: caml-list

I have a program compiled to native code on a linux machine, which uses 
some more-or-less "standard" library like libpangocairo-1.0.so.0.
Since this library is not universally present on all linux boxes, I 
suspect it might be not so easy for an average user to install it. 
Moreover, it's very small. Therefore I decide to ship it with my software.

The question is: is there a way to decide, at run-time, whether the user 
already has this library or not ? If so, I can ignore (and even delete) 
the version I shipped, and use the user's library. If not, I fall back 
on "my" version.


San


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

end of thread, other threads:[~2007-03-15 14:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-15 13:42 dynamically finding libraries Vu Ngoc San
     [not found] ` <1173969084.11071.16.camel@rosella.wigram>
2007-03-15 14:56   ` [Caml-list] " Vu Ngoc San
  -- strict thread matches above, loose matches on Subject: below --
2007-03-14 22:25 Style and organization of code ian
2007-03-15 13:38 ` dynamically finding libraries Vu Ngoc San

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