libclntsh.so.12.1 : cannot open shared object file error when running sample of node-oracledb

Ishan picture Ishan · Mar 29, 2015 · Viewed 29.8k times · Source

My goal is to connect to a oracle database on a VMWare guest machine (OpenSuse) from Ubuntu.

For now I have only installed the oracledb driver, and was trying to run the example connect program given.

The steps that I am following are from the github INSTALL page. What I have done till now are these :

1) Since I have node.js already installed I skipped the step 3.1.

2) I have successfully downloaded and extracted the basic and sdk as mentioned in step 3.2.

3) Since I couldn't find any package named libaio but I did found libaio1. So I installed libaio1.

4) I made the environment variable LD_LIBRARY_PATH and the contents of it on my PC is /opt/oracle/instantclient.

5) As mentioned in step 3.3; even though it wasn't mandatory in my case; I made two environment variables: OCI_LIB_DIR with contents /opt/oracle/instantclient and OCI_INC_DIR with contents /opt/oracle/instantclient/sdk/include.

6) Installed node-oracledb.

I am trying to run the example connect program. The code that I am using is here https://github.com/ishanatmuz/oracle-test. When I run node connect.js I am getting this error.

/home/ishan/node.js/oracle-test/node_modules/oracledb/lib/oracledb.js:28
throw err;
          ^
Error: libclntsh.so.12.1: cannot open shared object file: No such file or directory
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/ishan/node.js/oracle-test/node_modules/oracledb/lib/oracledb.js:23:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (modullibclntsh.so.12.1e.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Since I haven't started the VMware guest machine yet; I was hoping of getting an error regarding no such database instance found. And then only after that run the VMWare machine and connect to the database inside it. But instead I am getting the error of cannot open shared object file for libclntsh.so.12.1.

Answer

Christopher Jones picture Christopher Jones · Apr 17, 2015

My first suspicion would be that LD_LIBRARY_PATH is not actually set or exported correctly. Triple-check it is set and the directory is readable by the actual shell that attempts to start node.

export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2

You need to do this in any shell that starts Node.js.

I'd also check what other Oracle libraries are installed on the machine and make sure you don't have clashes.

Using ldconfig to set the path globally will almost certainly be easier than setting LD_LIBRARY_PATH. You can do something like:

sudo sh -c "echo /opt/oracle/instantclient_12_2 > /etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig

See the Instant Client install instructions for details.

If you have optional Net configuration files like sqlnet.ora or tnsnames.ora, they can be put in a directory /opt/oracle/instantclient_12_2/network/admin which is a default location for configuration files. See Optional Oracle Net Configuration.

Update: if you install the Instant Client 19.3 RPM packages, the ldconfig step is automatically done. (You still need/could/should do it for a 19.3 ZIP file install)

Instant Client 19 will connect to Oracle Database 11.2 or later, so use Instant Client 19 unless you have a special requirement for an older version.