* setting env variable from Guile
@ 2005-07-28 14:00 Aurelien Chanudet
2005-07-29 7:28 ` David Pirotte
0 siblings, 1 reply; 9+ messages in thread
From: Aurelien Chanudet @ 2005-07-28 14:00 UTC (permalink / raw)
Hi all,
I have a dynamic library located in a non standard
place I'd like to load within guile using
"dynamic-link". The dynamic link editor can be told
where to look for the library using an environment
variable. Is there a way to set up the environnement
variable directly _from_ Guile using for instance the
"system" primitive ?
Thanks,
Aurelien
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* setting env variable from Guile
@ 2005-07-28 15:55 Aurelien Chanudet
2005-07-29 14:29 ` José Roberto B. de A. Monteiro
0 siblings, 1 reply; 9+ messages in thread
From: Aurelien Chanudet @ 2005-07-28 15:55 UTC (permalink / raw)
Hi all,
I have a dynamic library located in a non standard
place I'd like to load within guile using
"dynamic-link". The dynamic link editor can be told
where to look for the library using an environment
variable. Is there a way to set up the environnement
variable directly _from_ Guile using for instance the
"system" primitive ?
Thanks,
Aurelien
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: setting env variable from Guile
2005-07-28 14:00 Aurelien Chanudet
@ 2005-07-29 7:28 ` David Pirotte
0 siblings, 0 replies; 9+ messages in thread
From: David Pirotte @ 2005-07-29 7:28 UTC (permalink / raw)
Cc: guile-user, ralubrik
setenv:
(setenv "PGCLIENTENCODING" "UNICODE")
> Is there a way to set up the environnement
> variable directly _from_ Guile using for instance the
> "system" primitive ?
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: setting env variable from Guile
2005-07-28 15:55 setting env variable from Guile Aurelien Chanudet
@ 2005-07-29 14:29 ` José Roberto B. de A. Monteiro
2005-07-29 15:32 ` Aurelien Chanudet
0 siblings, 1 reply; 9+ messages in thread
From: José Roberto B. de A. Monteiro @ 2005-07-29 14:29 UTC (permalink / raw)
On Thu, Jul 28, 2005 at 05:55:59PM +0200, Aurelien Chanudet wrote:
> Hi all,
>
> I have a dynamic library located in a non standard
> place I'd like to load within guile using
> "dynamic-link". The dynamic link editor can be told
> where to look for the library using an environment
> variable. Is there a way to set up the environnement
> variable directly _from_ Guile using for instance the
> "system" primitive ?
Have you ever tried to use Guile primitive function setenv ?
(setenv name value)
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: setting env variable from Guile
2005-07-29 14:29 ` José Roberto B. de A. Monteiro
@ 2005-07-29 15:32 ` Aurelien Chanudet
2005-07-29 19:20 ` Christian Mauduit
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Aurelien Chanudet @ 2005-07-29 15:32 UTC (permalink / raw)
Cc: guile-user
Thank you guys for the tip.
Unfortunately, the environnement variable set in this way doesn't
appear to be visible from the shell guile was launched from. As a
result, the environnement variable does not appear to be visible to
the dynamic link editor.
On 7/29/05, José Roberto B. de A. Monteiro <betoes@igbt.sel.eesc.usp.br> wrote:
> On Thu, Jul 28, 2005 at 05:55:59PM +0200, Aurelien Chanudet wrote:
> > Hi all,
> >
> > I have a dynamic library located in a non standard
> > place I'd like to load within guile using
> > "dynamic-link". The dynamic link editor can be told
> > where to look for the library using an environment
> > variable. Is there a way to set up the environnement
> > variable directly _from_ Guile using for instance the
> > "system" primitive ?
>
> Have you ever tried to use Guile primitive function setenv ?
>
> (setenv name value)
>
>
>
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: setting env variable from Guile
2005-07-29 15:32 ` Aurelien Chanudet
@ 2005-07-29 19:20 ` Christian Mauduit
2005-07-30 13:47 ` Mike Gran
2005-08-01 14:28 ` Jon Wilson
2 siblings, 0 replies; 9+ messages in thread
From: Christian Mauduit @ 2005-07-29 19:20 UTC (permalink / raw)
Cc: guile-user
Hi,
Aurelien Chanudet a écrit :
> Thank you guys for the tip.
>
> Unfortunately, the environnement variable set in this way doesn't
> appear to be visible from the shell guile was launched from. As a
> result, the environnement variable does not appear to be visible to
> the dynamic link editor.
AFAIK this is a UNIX limitation, using setenv within a program will only
change environnement variables for *this* program. Try to execute the
script shell:
#!/bin/bash
export FOO=bar
and FOO won't be set in the "parent" shell. Type directly:
export FOO=bar
and it will be set. Point is the "export" command is interpreted by this
parent shell, so it has means to set in within this shell. No idea how
to do this with Guile, except setting your environnement variable from
Guile and then launch your program _from_ Guile. The way bash does 8-)
Hope this will help.
Christian.
--
Christian Mauduit <ufoot@ufoot.org> __/\__ ___
\~/ ~/(`_ \ ___
http://www.ufoot.org/ /_o _\ \ \_/ _ \_
http://www.ufoot.org/gnupg.pub \/ \___/ \__)
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: setting env variable from Guile
2005-07-29 15:32 ` Aurelien Chanudet
2005-07-29 19:20 ` Christian Mauduit
@ 2005-07-30 13:47 ` Mike Gran
2005-07-30 15:12 ` Thien-Thi Nguyen
2005-08-01 14:28 ` Jon Wilson
2 siblings, 1 reply; 9+ messages in thread
From: Mike Gran @ 2005-07-30 13:47 UTC (permalink / raw)
Cc: guile-user
There are four things that should work, but, that I haven't tried out
yet.
You could call "dynamic-link" with the explicit pathname plus filename
to your library.
If your app is a pure guile script, you could write a wrapper shell
script that exports the environment variable you need and then calls
the guile script.
If you have a C main(), you could call lt_dladdsearchdir(const char *)
from C before dlopening your library.
You could wrap the function lt_dladdsearchdir as a Guile function and
call it from your script.
--
Mike
--- Aurelien Chanudet <aurelien.chanudet@gmail.com> wrote:
> Thank you guys for the tip.
>
> Unfortunately, the environnement variable set in this way doesn't
> appear to be visible from the shell guile was launched from. As a
> result, the environnement variable does not appear to be visible to
> the dynamic link editor.
>
> On 7/29/05, José Roberto B. de A. Monteiro
> <betoes@igbt.sel.eesc.usp.br> wrote:
> > On Thu, Jul 28, 2005 at 05:55:59PM +0200, Aurelien Chanudet wrote:
> > > Hi all,
> > >
> > > I have a dynamic library located in a non standard
> > > place I'd like to load within guile using
> > > "dynamic-link". The dynamic link editor can be told
> > > where to look for the library using an environment
> > > variable. Is there a way to set up the environnement
> > > variable directly _from_ Guile using for instance the
> > > "system" primitive ?
> >
> > Have you ever tried to use Guile primitive function setenv ?
> >
> > (setenv name value)
> >
> >
> >
>
>
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://lists.gnu.org/mailman/listinfo/guile-user
>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: setting env variable from Guile
2005-07-30 13:47 ` Mike Gran
@ 2005-07-30 15:12 ` Thien-Thi Nguyen
0 siblings, 0 replies; 9+ messages in thread
From: Thien-Thi Nguyen @ 2005-07-30 15:12 UTC (permalink / raw)
Cc: aurelien.chanudet, guile-user
From: Mike Gran <spk121@yahoo.com>
Date: Sat, 30 Jul 2005 06:47:57 -0700 (PDT)
You could wrap the function lt_dladdsearchdir as
a Guile function and call it from your script.
fyi, this is the approach taken in Guile 1.4.x,
as implemented in libguile/lt.c, below. works fine.
thi
_____________________________________________________
/* lt.c */
/* Copyright (C) 2002 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
/* This is wrapper code for libltdl. It should be possible to generate
it completely at some point. */
\f
#include <stdio.h>
#include "libguile/_scm.h"
#include "libguile/eq.h"
#include "libguile/list.h"
#include "libguile/validate.h"
#include "libguile/strings.h"
#include "libguile/lt.h"
#include "libltdl/ltdl.h"
static SCM
add_search_dir_x (char *dir)
{
if (0 == lt_dladdsearchdir (dir))
return SCM_UNSPECIFIED;
scm_misc_error (NULL, (char *) lt_dlerror (), SCM_EOL);
}
static SCM
set_search_path_x (char *path)
{
return ((0 == lt_dlsetsearchpath (path))
? SCM_BOOL_T
: SCM_BOOL_F);
}
static SCM
get_search_path (void)
{
return scm_makfrom0str_opt (lt_dlgetsearchpath ());
}
/* This is an experimental interface so we use a named command approach
and use a "double %" prefix. */
SCM_GLOBAL_SYMBOL (scm_sym_add_search_dir_x, "add-search-dir!");
SCM_GLOBAL_SYMBOL (scm_sym_set_search_path_x, "set-search-path!");
SCM_GLOBAL_SYMBOL (scm_sym_get_search_path, "get-search-path");
SCM_DEFINE (scm_percent_percent_ltdl, "%%ltdl", 1, 0, 1,
(SCM command, SCM args),
"Dispatch @var{command} given @var{args}, where\n"
"@var{command} is one of @code{add-search-dir!},\n"
"@code{set-search-path!}, or @code{get-search-path}\n"
"(a symbol). This interface is highly experimental.\n")
#define FUNC_NAME s_scm_percent_percent_ltdl
{
SCM_VALIDATE_SYMBOL (1, command);
/* add-search-dir! */
if (SCM_EQ_P (command, scm_sym_add_search_dir_x))
return add_search_dir_x (SCM_ROCHARS (SCM_CAR (args)));
/* set-search-path! */
if (SCM_EQ_P (command, scm_sym_set_search_path_x))
return set_search_path_x (SCM_ROCHARS (SCM_CAR (args)));
/* get-search-path */
if (SCM_EQ_P (command, scm_sym_get_search_path))
return get_search_path ();
/* badness */
scm_misc_error (NULL, "bad command", SCM_EOL);
}
#undef FUNC_NAME
\f
void
scm_init_lt ()
{
#include "libguile/lt.x"
}
/* lt.c ends here */
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: setting env variable from Guile
2005-07-29 15:32 ` Aurelien Chanudet
2005-07-29 19:20 ` Christian Mauduit
2005-07-30 13:47 ` Mike Gran
@ 2005-08-01 14:28 ` Jon Wilson
2 siblings, 0 replies; 9+ messages in thread
From: Jon Wilson @ 2005-08-01 14:28 UTC (permalink / raw)
Hi Aurelien,
Aurelien Chanudet wrote:
> Thank you guys for the tip.
>
> Unfortunately, the environnement variable set in this way doesn't
> appear to be visible from the shell guile was launched from. As a
> result, the environnement variable does not appear to be visible to
> the dynamic link editor.
>
Why does the dynamic link editor look in the parent shell's
environment? Shouldn't it look in the guile interpreter's
environment? If it is looking at the parent environ, I would have to
wonder if this is a bug in guile.
Regards,
Jon
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-08-01 14:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-28 15:55 setting env variable from Guile Aurelien Chanudet
2005-07-29 14:29 ` José Roberto B. de A. Monteiro
2005-07-29 15:32 ` Aurelien Chanudet
2005-07-29 19:20 ` Christian Mauduit
2005-07-30 13:47 ` Mike Gran
2005-07-30 15:12 ` Thien-Thi Nguyen
2005-08-01 14:28 ` Jon Wilson
-- strict thread matches above, loose matches on Subject: below --
2005-07-28 14:00 Aurelien Chanudet
2005-07-29 7:28 ` David Pirotte
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 read-only IMAP folder(s) and NNTP newsgroup(s).