I want to integrate the aerospike erlang client to the erlang environment as a global module in Fedora 21. I achieve to make the client nif and module but I have to always copy the files in every project. Now I want to use the aerospike module like the erlang or os modules. How can I make this?
Asked
Active
Viewed 148 times
1 Answers
0
I had the same issue when experimenting with the Aerospike binding. The problem is that the .so
file is assumed to be in the current working directory. I made a small change to aerospike.erl
so it's located correctly independent of the path.
Replace
ok = erlang:load_nif("./aerospike_nif", 0).
in init()
with
EbinDir = filename:dirname(code:which(?MODULE)),
SoFile = filename:join(EbinDir,"aerospike_nif"),
erlang:load_nif(SoFile, 0).
When starting erl
, add the path to the directory containing the Aerospike beam files and .so
: erl -pa path_to_aerospike/erlang/

johlo
- 5,422
- 1
- 18
- 32
-
I can work with that, thank you. what means this sentence ? `code:which(?MODULE)` – jasmad May 11 '15 at 18:38
-
`?MODULE` is a macro that evaluates to the name of the current module, `aerospike` in this case. `code:which/1` returns the absolute path to the file that contains the module definition. – johlo May 11 '15 at 18:58