We had a discussion about this last week, I think. The archives may help
you with more details, but here's an overview:
* It seems like it works if you put it in an init.tcl for a Tcl module, as
defined in your nsd.tcl
* If I recall, you can load it in a tcl script by doing
ns_eval [list load /path/to/file.so]
one time, and it will exist in all interpreters. Of course, you'll
probably want to wrap this up so that it doesn't get loaded every time.
Perhaps something like:
if ![ nsv_exists lib_loaded file.so ] {
ns_eval [list load /path/to/file.so]
nsv_set lib_loaded file.so 1
}
or, it may be possible to do something like
if ![ string length [info commands some_command] ] {
ns_eval [list load /path/to/file.so]
}
(where some_command is a command defined in file.so, which would not be
defined without it. I may have the syntax wrong with info commands, you
should check on that.
* My personal method is to make a shim to load the tcl module as an
AOLServer module. Essentially you just need to provide a crappy little
Ns_ModuleInit() like this:
int Ns_ModuleInit(char *server, char *module) {
extern int Pdflib_Init();
return Ns_TclInitInterps(server, Pdflib_Init, NULL);
}
This could be compiled in with the .so, or it's possible you could have it
independantly in a seperate .so if (in this case) pdflib.so was in your
LD_LIBRARY_PATH. Ns_ModuleInit just needs to have a call to the Tcl
initialization procedure for your tcl module, what you would usually put
in Tcl_AppInit if you were compiling it in as a static library in a custom
tcl executable.
I hope this gives you some places to start,
Rusty
On Sun, 7 Apr 2002, Christian Wilhelmi wrote:
> Hi,
>
> I've got a compiled Tcl-library (.so) that I currently load once for every
> script that's being interpreted. I am sure there exists some smarter way by
> which the file can be loaded once at aolserver startup, I just don't know
> how. Could someone give me a hint as to this?
> Thanks in advance,
>
> Christian
>
------------------------------------------
Rusty Brooks : http://www.rustybrooks.org/
Spewing wisdom from every orifice
------------------------------------------