[SOLVED][unixODBC] Can\'t open lib

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
4 posts • Page 1 of 1
yosu
Posts:22
Joined: Wed Mar 14, 2012 4:14 pm

[SOLVED][unixODBC] Can\'t open lib

Post by yosu »

I am trying to connect to an oracle database via odbc. The command "isql test-odbc" connects to database from command line with the same user running WinCCOA.

I run this code in a push button:

Code: Select all

main()
{
  int rc;
  dbConnection conn;
  rc = dbOpenConnection("DSN=test-odbc;", conn);
}
Logviewer show an error:

Code: Select all

dbOpenConnection, DSN=test-odbc;DB:[unixODBC][Driver Manager]Can't open lib '/usr/lib/oracle/11.2/client64/lib/libsqora.so.11.1' : file not found;DRV:QODBC3: Unable to connect
Am I missing anything? What is it wrong? If isql command is working from command line, why not dbOpenConnection()?

Greetings

a.decelis
Posts:30
Joined: Thu Jun 25, 2015 6:42 pm

Re: [unixODBC] Can\'t open lib

Post by a.decelis »

Check your LD_LIBRARY_PATH environment variable and be sure it contains the path to your Oracle libraries.

yosu
Posts:22
Joined: Wed Mar 14, 2012 4:14 pm

Re: [unixODBC] Can\'t open lib

Post by yosu »

Alejandro C wrote:
Check your LD_LIBRARY_PATH environment variable and be sure it contains the path to your Oracle libraries.
Thanks for point to this.

I have already set up all oracle environment variables in /etc/profile.d/oracleenv.sh but this is only loaded by interactive shells. So I move oracle environment variables to /etc/environment and it works!

By the way, I need to setup all this environment variables:
LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib
ORACLE_HOME=/usr/lib/oracle/12.2/client64
TNS_ADMIN=/usr/lib/oracle/12.2/client64/network/admin
ORACLE_HOME=/usr/lib/oracle/12.2/client64
ORACLE_SID=db_test
#TWO_TASK=//database:port/service_name
TWO_TASK=//dbmachine:1521/XE

yosu
Posts:22
Joined: Wed Mar 14, 2012 4:14 pm

Re: [SOLVED][unixODBC] Can\'t open lib

Post by yosu »

As I am running the project as a service I need to add to the systemd service a new folder with file /etc/systemd/system/winccoa@.service.d/oracle_env.conf in order to add my environment variables. File content is as follows:

Code: Select all

[Service]
Environment="LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib"
Environment="TWO_TASK=//oracle-server.local:1521/MYDB"
Environment="ODBCINI=/home/scada/.odbc.ini"
In /home/scada/.odbc.ini I need to change driver in orther to work as a service. If not, I get error "data source not found". Before was:

Code: Select all

Driver = OracleODBC-12.2
Now is:

Code: Select all

Driver = /usr/lib/oracle/12.2/client64/lib/libsqora.so.12.1

4 posts • Page 1 of 1