mariano / node-db-oracle

Oracle database bindings for Node.js
http://nodejsdb.org
141 stars 34 forks source link

Unable to load shared library after compile (Ubuntu and Mac OS X) #24

Closed drudge closed 12 years ago

drudge commented 12 years ago

I have been trying to get this library working for a while now. I've attempted on Node 0.4.x as well as 0.6.x with no success. I can get the module built, however trying to use it yields an error message stating it can't load the shared library. Any assistance would be greatly appreciated.

My /opt/instantclient directory structure:

# ls -lah /opt/instantclient/
total 169M
drwxr-xr-x 3 drudge drudge 4.0K Dec 28 17:51 .
drwxr-xr-x 3 drudge drudge 4.0K Dec 28 17:33 ..
-rw-r--r-- 1 drudge drudge  437 Dec 28 17:33 BASIC_README
-rwxr-xr-x 1 drudge drudge  22K Dec 28 17:33 adrci
-rwxr-xr-x 1 drudge drudge  38K Dec 28 17:33 genezi
lrwxrwxrwx 1 drudge drudge   17 Dec 28 17:51 libclntsh.so -> libclntsh.so.11.1
-rwxr-xr-x 1 drudge drudge  42M Dec 28 17:33 libclntsh.so.11.1
-r-xr-xr-x 1 drudge drudge 6.8M Dec 28 17:33 libnnz11.so
lrwxrwxrwx 1 drudge drudge   15 Dec 28 17:46 libocci.so -> libocci.so.11.1
-rwxr-xr-x 1 drudge drudge 1.8M Dec 28 17:33 libocci.so.11.1
-rwxr-xr-x 1 drudge drudge 113M Dec 28 17:33 libociei.so
-r-xr-xr-x 1 drudge drudge 149K Dec 28 17:33 libocijdbc11.so
-r--r--r-- 1 drudge drudge 2.0M Dec 28 17:33 ojdbc5.jar
-r--r--r-- 1 drudge drudge 2.6M Dec 28 17:33 ojdbc6.jar
drwxrwxr-x 4 drudge drudge 4.0K Sep 19 03:12 sdk
-rwxr-xr-x 1 drudge drudge 157K Dec 28 17:33 uidrvci
-rw-r--r-- 1 drudge drudge  66K Dec 28 17:33 xstreams.jar

Installation via npm:

# export OCI_LIB_DIR=/opt/instantclient
# export OCI_INCLUDE_DIR=/opt/instantclient/sdk/include/
# npm install db-oracle
npm http GET https://registry.npmjs.org/db-oracle
npm http 304 https://registry.npmjs.org/db-oracle

> db-oracle@0.2.2 install /home/drudge/test/node_modules/db-oracle
> node-waf configure build

Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
Checking for header occi.h               : yes 
Checking for library occi                : yes 
'configure' finished successfully (0.492s)
Waf: Entering directory `/home/drudge/test/node_modules/db-oracle/build'
[ 1/12] cxx: lib/node-db/binding.cc -> build/Release/lib/node-db/binding_1.o
[ 2/12] cxx: lib/node-db/connection.cc -> build/Release/lib/node-db/connection_1.o
[ 3/12] cxx: lib/node-db/events.cc -> build/Release/lib/node-db/events_1.o
[ 4/12] cxx: lib/node-db/exception.cc -> build/Release/lib/node-db/exception_1.o
[ 5/12] cxx: lib/node-db/query.cc -> build/Release/lib/node-db/query_1.o
[ 6/12] cxx: lib/node-db/result.cc -> build/Release/lib/node-db/result_1.o
[ 7/12] cxx: src/connection.cc -> build/Release/src/connection_1.o
[ 8/12] cxx: src/oracle.cc -> build/Release/src/oracle_1.o
[ 9/12] cxx: src/query.cc -> build/Release/src/query_1.o
[10/12] cxx: src/result.cc -> build/Release/src/result_1.o
[11/12] cxx: src/oracle_bindings.cc -> build/Release/src/oracle_bindings_1.o
[12/12] cxx_link: build/Release/lib/node-db/binding_1.o build/Release/lib/node-db/connection_1.o build/Release/lib/node-db/events_1.o build/Release/lib/node-db/exception_1.o build/Release/lib/node-db/query_1.o build/Release/lib/node-db/result_1.o build/Release/src/connection_1.o build/Release/src/oracle_1.o build/Release/src/query_1.o build/Release/src/result_1.o build/Release/src/oracle_bindings_1.o -> build/Release/oracle_bindings.node
Waf: Leaving directory `/home/drudge/test/node_modules/db-oracle/build'
'build' finished successfully (4.173s)

My test code (test.js):

var oracle = require('db-oracle');
new oracle.Database({
    hostname: 'localhost',
    user: 'drudge',
    password: 'password',
    database: 'node'
}).connect(function(error) {
    if (error) {
        return console.log("CONNECTION ERROR: " + error);
    }

    this.query().select('*').from('users').execute(function(error, rows) {
        if (error) {
            return console.log('ERROR: ' + error);
        }
        console.log(rows.length + ' ROWS');
    });
});

And the error:

# node test.js 

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Unable to load shared library /home/drudge/test/node_modules/db-oracle/build/Release/oracle_bindings.node
    at Object..node (module.js:463:11)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Module.require (module.js:357:17)
    at require (module.js:368:17)
    at Object.<anonymous> (/home/drudge/test/node_modules/db-oracle/db-oracle.js:18:15)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)

Versions:

tritowntim commented 12 years ago

Been fighting this all day, same error. Are you Lion? Probably same issue as this https://github.com/mariano/node-db-oracle/issues/9

drudge commented 12 years ago

For Mac I was testing on Lion, however it doesn't explain why I get this error on Ubuntu.

jmandel commented 12 years ago

I'm experiencing the same behavior on an Ubuntu 11.10 setup. Works for me if I set an environment variable LD_LIBRARY_PATH:

$ LD_LIBRARY_PATH=/opt/instantclient/  node test.js

If this works you can do (as root):

$ cat > /etc/ld.so.conf.d/oracle.conf
/opt/instantclient
<ctrl-d>

$ ldconfig
j-5-s commented 12 years ago

geting the same issue on ubuntu 11.10. the shared library located at ./build/Release/oracle_bindings can not be loaded. any ideas. install seemed to go fine. Also,
LD_LIBRARY_PATH=/opt/instantclient/ node test.js does not seem to work

kimwz commented 12 years ago

I found the answer.

$ export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib/ <-- this is your oracle library path

and try again

cebbec commented 12 years ago

Try this, it works for me:

sudo apt-get install libaio1

rbriank commented 12 years ago

I've got the same problem as the OP and none of these suggestions have worked. I'm on Snow Leopard.

I didn't try install the full client. Is it possible to get working with instant client?

mariano commented 12 years ago

The new README should answer these questions