# Can't run oracle instant client with unixODBC



## hasculdr (Sep 19, 2022)

Hello. I have 13.1-STABLE OS version and oracle instant client 64-bit for linux. I have enabled linux binary compatibility and unpacked client's files into /compat/linux/opt/oracle/instantclient_10_2 (i need exactly this version):

```
ls -l /compat/linux/opt/oracle/instantclient_10_2/
total 112634
-r--r--r--  1 root  wheel   1621582 20 апр.   2010 classes12.jar
-rwxrwxr-x  1 root  wheel     70742 20 апр.   2010 genezi
-r--r--r--  1 root  wheel      1525 20 апр.   2010 glogin.sql
lrwxr-xr-x  1 root  wheel        17 13 сент. 15:07 libclntsh.so -> libclntsh.so.10.1
-rwxrwxr-x  1 root  wheel  25306574 20 апр.   2010 libclntsh.so.10.1
-r-xr-xr-x  1 root  wheel   7856305 20 апр.   2010 libnnz10.so
lrwxr-xr-x  1 root  wheel        15 13 сент. 15:07 libocci.so -> libocci.so.10.1
-rwxrwxr-x  1 root  wheel   1669888 20 апр.   2010 libocci.so.10.1
-rwxrwxr-x  1 root  wheel  72703820 20 апр.   2010 libociei.so
-r-xr-xr-x  1 root  wheel    150417 20 апр.   2010 libocijdbc10.so
-r-xr-xr-x  1 root  wheel   1345921 20 апр.   2010 libsqlplus.so
-r-xr-xr-x  1 root  wheel   1436497 20 апр.   2010 libsqlplusic.so
lrwxr-xr-x  1 root  wheel        18 14 сент. 14:57 libsqora.so -> ./libsqora.so.10.1
-rwxrwxr-x  1 root  wheel   1016119 20 апр.   2010 libsqora.so.10.1
drwxr-xr-x  3 root  wheel         3 13 сент. 15:14 network
-r--r--r-x  1 root  wheel      3589 20 апр.   2010 odbc_update_ini.sh
-r--r--r--  1 root  wheel   1569316 20 апр.   2010 ojdbc14.jar
-r-xr-xr-x  1 root  wheel      9317 20 апр.   2010 sqlplus
```
With oracle instruction I've done:

```
ln -s libclntsh.so.10.1 libclntsh.so
ln -s libocci.so.10.1 libocci.so
```
Install the libaio package:

```
# pkg version | grep linux
linux-c7-libaio-0.3.109            =
linux_base-c7-7.9.2009             =
```


```
sudo sh -c "echo /compat/linux/opt/oracle/instantclient_10_2 > /compat/linux/etc/ld.so.conf.d/oracle-instantclient.conf
sudo ldconfig
```
and export some env variables:

```
$ env
ODBCSYSINI=/usr/local/etc
ODBCINI=/home/zabbix/.odbc.ini
ORACLE_HOME=/compat/linux/opt/oracle/instantclient_10_2
PATH=/compat/linux/opt/oracle/instantclient_10_2:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/zabbix/bin
LD_LIBRARY_PATH=/compat/linux/lib:/compat/linux/lib64:/compat/linux/opt/oracle/instantclient_10_2
```
Now I can use sqlplus, but when I try use `isql - i` get this error (I wrote driver settings right in ~/.odbc.ini:
`Driver=/compat/linux/opt/oracle/instantclient_10_2/libsqora.so`):

```
$ isql -v SR
[01000][unixODBC][Driver Manager]Can't open lib '/compat/linux/opt/oracle/instantclient_10_2/libsqora.so' : file not found
[ISQL]ERROR: Could not SQLConnect
```
Anyone has any advices where I'm wrong?


----------



## covacat (Sep 19, 2022)

try to ldd (with linux ldd) /compat/linux/opt/oracle/instantclient_10_2/libsqora.so and see if you have all its deps


----------



## hasculdr (Sep 20, 2022)

```
# /compat/linux/bin/ldd /compat/linux/opt/oracle/instantclient_10_2/libsqora.so
bash: /compat/linux/bin/ldd: /usr/bin/bash: bad interpreter: No such file or directory
```
but

```
# /compat/linux/bin/bash /compat/linux/bin/ldd /compat/linux/opt/oracle/instantclient_10_2/libsqora.so
        linux-vdso.so.1 =>  (0x00007fffffffe000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000000801600000)
        libm.so.6 => /lib64/libm.so.6 (0x0000000801a00000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000000801e00000)
        libnsl.so.1 => /lib64/libnsl.so.1 (0x0000000802200000)
        libclntsh.so.10.1 => not found
        libodbcinst.so.1 => not found
        libc.so.6 => /lib64/libc.so.6 (0x0000000802600000)
        /lib64/ld-linux-x86-64.so.2 (0x0000000001021000)
```
I have the first one

```
# ls -l /compat/linux/opt/oracle/instantclient_10_2/ | grep libclntsh
lrwxr-xr-x  1 root  wheel        17 13 сент. 15:07 libclntsh.so -> libclntsh.so.10.1
-rwxrwxr-x  1 root  wheel  25306574 20 апр.   2010 libclntsh.so.10.1
```
and I haven't the libodbcinst.so.1. Why linux ldd can't see libclntsh.so.10.1?


----------



## covacat (Sep 20, 2022)

set LD_LIBRARY_PATH or edit ld.so search paths config


----------



## hasculdr (Sep 20, 2022)

it's already done:


> $ env | grep LD_
> LD_LIBRARY_PATH=/compat/linux/lib:/compat/linux/lib64:/compat/linux/opt/oracle/instantclient_10_2





> $ cat /compat/linux/etc/ld.so.conf.d/oracle-instantclient.conf
> /compat/linux/opt/oracle/instantclient_10_2


Does the prefix "/compat/linux" must be in .conf file? I added it now, but early the record was as


> > $ cat /compat/linux/etc/ld.so.conf.d/oracle-instantclient.conf
> > /opt/oracle/instantclient_10_2


i run `# /compat/linux/sbin/ldconfig` and now


> # /compat/linux/bin/bash /compat/linux/bin/ldd /compat/linux/opt/oracle/instantclient_10_2/libsqora.so
> ...
> libclntsh.so.10.1 => /compat/linux/opt/oracle/instantclient_10_2/libclntsh.so.10.1 (0x0000000802600000)
> libodbcinst.so.1 => not found
> ...


Thanks, i'll try to find  libodbcinst.so.1.


----------



## covacat (Sep 20, 2022)

hasculdr said:


> it's already done:
> 
> 
> Does the prefix "/compat/linux" must be in .conf file? I added it now, but early the record was as
> ...


on freebsd it's part of unixODBC package


----------



## hasculdr (Sep 20, 2022)

> # ls -l /usr/local/lib | grep odbc
> -rw-r--r--   1 root  wheel   1296426 14 сент. 15:29 libodbc.a
> -rwxr-xr-x   1 root  wheel       925 14 сент. 15:29 libodbc.la
> lrwxr-xr-x   1 root  wheel        16 14 сент. 15:29 libodbc.so -> libodbc.so.2.0.0
> ...


there is newer library, i add symlink `ln -s libodbcinst.so.2 libodbcinst.so.1`
and modify LD_LIBRARY_PATH:


> $ env | grep LD_
> LD_LIBRARY_PATH=/compat/linux/lib:/compat/linux/lib64:/usr/local/lib:/compat/linux/opt/oracle/instantclient_10_2


The result is


> $ /compat/linux/bin/bash /compat/linux/bin/ldd /compat/linux/opt/oracle/instantclient_10_2/libsqora.so
> /compat/linux/opt/oracle/instantclient_10_2/libsqora.so: error while loading shared libraries: /usr/local/lib/libodbcinst.so.1: ELF file OS ABI invalid


----------



## covacat (Sep 20, 2022)

do not put /usr/local/lib in ld_library_path because there's where freebsd libs reside
thats why you get invalid abi


----------



## hasculdr (Sep 20, 2022)

I removed it and reuse /compal/linux/sbin/ldconfig

```
$ ls -l /usr/local/lib | grep libodbcinst
-rw-r--r--   1 root  wheel    347918 Sep 14 15:29 libodbcinst.a
-rwxr-xr-x   1 root  wheel       953 Sep 14 15:29 libodbcinst.la
lrwxr-xr-x   1 root  wheel        20 Sep 14 15:29 libodbcinst.so -> libodbcinst.so.2.0.0
lrwxr-xr-x   1 root  wheel        16 Sep 20 14:13 libodbcinst.so.1 -> libodbcinst.so.2
lrwxr-xr-x   1 root  wheel        20 Sep 14 15:29 libodbcinst.so.2 -> libodbcinst.so.2.0.0
-rwxr-xr-x   1 root  wheel     98288 Sep 14 15:29 libodbcinst.so.2.0.0
```


```
$ /compat/linux/bin/bash /compat/linux/bin/ldd /compat/linux/opt/oracle/instantclient_10_2/libsqora.so
        ...
        libodbcinst.so.1 => not found
        ...
```


```
$ isql -v SR
ld-elf.so.1: /compat/linux/lib/libodbc.so.2: unsupported file layout
```
Now I'm trying to find the first version of this library.


----------



## hasculdr (Sep 20, 2022)

i don't understand how it works - i have an FreeBSD version of unixODBC package and a linux oracle client with linux libraries for it. Should i resolve this dependensy?

```
$ /compat/linux/bin/bash /compat/linux/bin/ldd /compat/linux/opt/oracle/instantclient_10_2/libsqora.so
        linux-vdso.so.1 =>  (0x00007fffffffe000)
        libdl.so.2 => /compat/linux/lib64/libdl.so.2 (0x0000000801600000)
        libm.so.6 => /compat/linux/lib64/libm.so.6 (0x0000000801a00000)
        libpthread.so.0 => /compat/linux/lib64/libpthread.so.0 (0x0000000801e00000)
        libnsl.so.1 => /compat/linux/lib64/libnsl.so.1 (0x0000000802200000)
        libclntsh.so.10.1 => /compat/linux/opt/oracle/instantclient_10_2/libclntsh.so.10.1 (0x0000000802600000)
        libodbcinst.so.1 => not found
        libc.so.6 => /compat/linux/lib64/libc.so.6 (0x0000000803c00000)
        /lib64/ld-linux-x86-64.so.2 (0x0000000001021000)
        libnnz10.so => /compat/linux/opt/oracle/instantclient_10_2/libnnz10.so (0x0000000804000000)
```
When i try to connect to database:

```
$ /usr/local/bin/isql -v SR
ld-elf.so.1: /compat/linux/lib/libodbc.so.2: unsupported file layout
$ /compat/linux/bin/bash /compat/linux/bin/ldd /compat/linux/lib/libodbc.so.2
        linux-gate.so.1 =>  (0xffffd000)
        libltdl.so.7 => /compat/linux/lib/libltdl.so.7 (0x21094000)
        libdl.so.2 => /compat/linux/lib/libdl.so.2 (0x2109f000)
        libpthread.so.0 => /compat/linux/lib/libpthread.so.0 (0x210a4000)
        libc.so.6 => /compat/linux/lib/libc.so.6 (0x210c0000)
        /lib/ld-linux.so.2 (0x01001000)
```
if i do that
`[root@SOMESERVER /compat/linux/opt/oracle/instantclient_10_2]# ln -s /compat/linux/lib64/libodbcinst.so.2.0.0 libodbcinst.so.1`
i can use $ /compat/linux/bin/isql -v SR, but i need to use the FreeBSD isql version.


----------



## covacat (Sep 20, 2022)

hasculdr said:


> i can use $ /compat/linux/bin/isql -v SR, but i need to use the FreeBSD isql version.


why ?


----------



## hasculdr (Sep 21, 2022)

it is for zabbix monitoring, i have some legacy oracle databases and some mysql/postgres; by default zabbix server uses system unixODBC.
is it possible to use system unixODBC with linux oracle client, or i just fantasized it?


----------



## maxi0250 (Dec 12, 2022)

I am currently working on the same problem (running UnixODBC with Oracle driver on FreeBSD).
I am also able to connect to the db via `/compat/linux/bin/isql`, but using FreeBSD's `isql` seems impossible.
It always throws this error:


> [01000][unixODBC][Driver Manager]Can't open lib '/opt/oracle/instantclient_21_7/libsqora.so.21.1' : file not found



I used `truss` and logged the output, and it seems like all required libraries are found.
`/compat/linux/bin/bash ldd -v /opt/orace/instantclient_21_7/libsqora.so.21.1` states the same (everything linked).


If someone could look inside the output from `truss` and check if they can find something?
Last 50 lines of Truss:

```
1379: 0.124064358 close(3)             = 0 (0x0)
 1379: 0.124225713 open("/opt/oracle/instantclient_21_7//ld-linux-x86-64.so.2",O_RDONLY|O_CLOEXEC|O_VERIFY,014232266000) ERR#2 'No such file or directory'
 1379: 0.124427313 open("/lib/ld-linux-x86-64.so.2",O_RDONLY|O_CLOEXEC|O_VERIFY,014232266000) ERR#2 'No such file or directory'
 1379: 0.124539101 open("/usr/lib/ld-linux-x86-64.so.2",O_RDONLY|O_CLOEXEC|O_VERIFY,014232266000) ERR#2 'No such file or directory'
 1379: 0.124706351 open("/usr/lib/compat/ld-linux-x86-64.so.2",O_RDONLY|O_CLOEXEC|O_VERIFY,014232266000) ERR#2 'No such file or directory'
 1379: 0.124832741 open("/usr/local/lib/ld-linux-x86-64.so.2",O_RDONLY|O_CLOEXEC|O_VERIFY,014232266000) ERR#2 'No such file or directory'
 1379: 0.124946306 open("/usr/local/lib/compat/pkg/ld-linux-x86-64.so.2",O_RDONLY|O_CLOEXEC|O_VERIFY,014232266000) ERR#2 'No such file or directory'
 1379: 0.125070184 open("/compat/linux/lib64/ld-linux-x86-64.so.2",O_RDONLY|O_CLOEXEC|O_VERIFY,014232266000) = 3 (0x3)
 1379: 0.125213891 fstat(3,{ mode=-rwxr-xr-x ,inode=3013,size=163312,blksize=131072 }) = 0 (0x0)
 1379: 0.125393216 fstatfs(3,{ fstypename=zfs,mntonname=/,mntfromname=zroot/ROOT/default,fsid=3fbe787ede922885 }) = 0 (0x0)
 1379: 0.125536369 mmap(0x0,4096,PROT_READ,MAP_PRIVATE|MAP_PREFAULT_READ,3,0x0) = 34362138624 (0x80024a000)
 1379: 0.125642479 mmap(0x0,2244608,PROT_NONE,MAP_GUARD,-1,0x0) = 34472452096 (0x806b7e000)
 1379: 0.125774471 mmap(0x806b7e000,139264,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE|MAP_PREFAULT_READ,3,0x0) = 34472452096 (0x806b7e000)
 1379: 0.125975239 mmap(0x806d9f000,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_PREFAULT_READ,3,0x21000) = 34474684416 (0x806d9f000)
 1379: 0.126117536 mmap(0x806da1000,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_ANON,-1,0x0) = 34474692608 (0x806da1000)
 1379: 0.126293644 munmap(0x80024a000,4096)     = 0 (0x0)
 1379: 0.126403901 close(3)             = 0 (0x0)
 1379: 0.126550429 open("/opt/oracle/instantclient_21_7//libnnz21.so",O_RDONLY|O_CLOEXEC|O_VERIFY,067000) = 3 (0x3)
 1379: 0.126705904 fstat(3,{ mode=-rwxr-xr-x ,inode=5872,size=5837512,blksize=131072 }) = 0 (0x0)
 1379: 0.126835039 fstatfs(3,{ fstypename=zfs,mntonname=/,mntfromname=zroot/ROOT/default,fsid=3fbe787ede922885 }) = 0 (0x0)
 1379: 0.126975769 mmap(0x0,4096,PROT_READ,MAP_PRIVATE|MAP_PREFAULT_READ,3,0x0) = 34362138624 (0x80024a000)
 1379: 0.127094366 mmap(0x0,4096,PROT_READ,MAP_PRIVATE,3,0x421000) = 34367516672 (0x80076b000)
 1379: 0.127304554 mmap(0x0,6770688,PROT_NONE,MAP_GUARD|MAP_ALIGNED_SUPER,-1,0x0) = 34475081728 (0x806e00000)
 1379: 0.127557357 mmap(0x806e00000,4333568,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE|MAP_PREFAULT_READ,3,0x0) = 34475081728 (0x806e00000)
 1379: 0.127712007 mmap(0x807421000,335872,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_PREFAULT_READ,3,0x421000) = 34481508352 (0x807421000)
 1379: 0.127859374 mmap(0x807473000,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_ANON,-1,0x0) = 34481844224 (0x807473000)
 1379: 0.128025979 munmap(0x80076b000,4096)     = 0 (0x0)
 1379: 0.128124192 munmap(0x80024a000,4096)     = 0 (0x0)
 1379: 0.128291344 close(3)             = 0 (0x0)
 1379: 0.128535529 munmap(0x801000000,2863104)     = 0 (0x0)
 1379: 0.128661320 munmap(0x8012bb000,2113536)     = 0 (0x0)
 1379: 0.128783682 munmap(0x8014bf000,3153920)     = 0 (0x0)
 1379: 0.128888780 munmap(0x8017c1000,2211840)     = 0 (0x0)
 1379: 0.128992302 munmap(0x800746000,36864)     = 0 (0x0)
 1379: 0.129096530 munmap(0x8019dd000,2105344)     = 0 (0x0)
 1379: 0.129311622 munmap(0x801bdf000,2203648)     = 0 (0x0)
 1379: 0.129915575 munmap(0x801e00000,71192576)     = 0 (0x0)
 1379: 0.130171145 munmap(0x806200000,5963776)     = 0 (0x0)
 1379: 0.130360505 munmap(0x80074f000,114688)     = 0 (0x0)
 1379: 0.130525865 munmap(0x8067b0000,3989504)     = 0 (0x0)
 1379: 0.130639257 munmap(0x806b7e000,2244608)     = 0 (0x0)
 1379: 0.130856698 munmap(0x806e00000,6770688)     = 0 (0x0)
 1379: 0.131158993 fstat(1,{ mode=crw--w---- ,inode=106,size=0,blksize=4096 }) = 0 (0x0)
 1379: 0.131472988 ioctl(1,TIOCGETA,0x7fffffffdf90) = 0 (0x0)
 1379: 0.131838650 write(1,"[01000][unixODBC][Driver Manager]Can't open lib '/opt/oracle/instantclient_21_7/libsqora.so.21.1' : file not found\n",115) = 115 (0x73)
 1379: 0.132189860 write(2,"[ISQL]ERROR: Could not SQLConnect\n",34) = 34 (0x22)
 1379: 0.132795733 exit(0x1)           
 1379: 0.132867583 process exit, rval = 1
```

--> Full Truss Output on Pastebin


----------

