os:putenv/2 not helping with erl_ddll:load_driver/2

Paul Mineiro paul-trapexit@REDACTED
Tue Sep 22 20:38:36 CEST 2009


I'm encountering a difference between os:putenv/2 and setting the
environment variable prior to invoking Erlang.

I'm trying to pick up a library that the os puts in a funny place,
which my linked-in driver depends upon.  Manipulating the environment
variable inside Erlang doesn't have the desired effect.

Does anybody have a workaround?  I don't want to have to restart the
emulator to install this software.

Thanks,

-- p

-----------
% erl -pa ../src
Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [kernel-poll:false]

Eshell V5.6.5  (abort with ^G)
1> os:getenv ("LD_LIBRARY_PATH").
"/home/pmineiro/lib:/usr/local/lib"
2> os:putenv ("LD_LIBRARY_PATH", "/usr/lib/lp_solve:/home/pmineiro/lib:/usr/local/lib").
true
3> os:getenv ("LD_LIBRARY_PATH").
"/usr/lib/lp_solve:/home/pmineiro/lib:/usr/local/lib"
4> erl_ddll:load_driver ("/usr/lib/", "liblpsolveerldrv").
{error,{open_error,-10}}
5> erl_ddll:format_error ({ open_error, -10 }).
"liblpsolve55.so: cannot open shared object file: No such file or
directory"
6>
User switch command
 --> q
% LD_LIBRARY_PATH="/usr/lib/lp_solve:/home/pmineiro/lib:/usr/local/lib" erl -pa ../src
Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [kernel-poll:false]

Eshell V5.6.5  (abort with ^G)
1> os:getenv ("LD_LIBRARY_PATH").
"/usr/lib/lp_solve:/home/pmineiro/lib:/usr/local/lib"
2> erl_ddll:load_driver ("/usr/lib/", "liblpsolveerldrv").
ok
3>
User switch command
 --> q
-----------


More information about the erlang-questions mailing list