Erlang : How to load sqlite3_drv.so

Create sqlite_1.erl

vim sqlite_1.erl

i have created it in /usr/local/myErl/

File content

-module(sqlite_1).
-export([load_driver/0]).
-define(DRV_PATH, "/opt/drivers/").
-define(DRV_NAME, "sqlite3_drv").

%% loads the sqlite_drv.so
load_driver() ->
  case erl_ddll:load(?DRV_PATH, ?DRV_NAME) of
    ok ->
      ok;
  Else ->
    io:fwrite("Unable to load sqlite3_drv~p~n", [{Else}])
  end.

How to run

[root@sam myErl]# erl
<pre>Erlang R14B (erts-5.8.1)

[smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.1 (abort with ^G)
1> c(sqlite_1).
{ok,sqlite_1}
2> m(sqlite_1).
Module sqlite_1 compiled: Date: December 11 2011, Time: 08.16
Compiler options: []
Object file: /usr/local/myErl/sqlite_1.beam
Exports:
 load_driver/0
 module_info/0
 module_info/1
ok
3> sqlite_1:load_driver().
ok
4>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: