Reputation: 315
I need to load a library in a LISP script.
The script "loader.lisp" and the library "mylib.dll" are in the same folder "parent_dir".
If I run the script from inside the folder (current directory = "parent_dir") it works fine:
(load "loader.lisp") ;OK lib loaded successfully
but if the current directory is somewhere else, it fails to load (of course it looks for the lib in the wrong dir):
(load "parent_dir/loader.lisp") ;ERROR, of course I'm in the wrong working dir!
;Error opening shared object "mylib.dll":
;dlopen(mylib.dll, 10): image not found.
The "loader.lisp" script contains (also) the following code:
(setq LIB_PATH "mylib.dll")
(if (string= (software-type) "Darwin")
(setq LIB_PATH "mylib_osx.lib"))
#+allegro
(load LIB_PATH)
#+sbcl
(sb-alien:load-shared-object LIB_PATH)
The question is: how can I make the loader.lisp script "working directory"-independent?
UPDATE: I specify that the script ant the interpreter executable are not in the same directory.
Thank you very much!
Upvotes: 0
Views: 675
Reputation: 7599
I would suggest the following solutions:
It's rather a question about concept of OS working directory than about Lisp itself.
As far as I see solution involving "PATH" variable could be the best one. You can just test this method and tell us if it worked.
Upvotes: 1