title: psqlODBC won't load after installing MS SQL ODBC driver on RHEL 6
body: <p>I had the PostgreSQL drivers working on my RHEL 6. But after I installed Microsoft® SQL Server® ODBC Driver 1.0 for Linux I can no longer connect to PosgreSQL data sources. I can connect to SQL Server data sources fine.</p>
  
  <p>When I had this same issue a week ago I uninstalled MS SQL Server ODBC driver from Linux and it fixed the issue. I removed MS SQL Server ODBC driver by executing the following commands:</p>
  
  <pre><code>rm /usr/bin/bcp
  rm /usr/bin/sqlcmd
  odbcinst -u -d -n "SQL Server Native Client 11.0"
  rm -r /opt/microsoft/sqlncli
  </code></pre>
  
  <p>I still had to copy the <code>psqlodbcw.so</code> file (MS drivers installation made them inaccessible despite their existence) from another Linux machine that had PostgreSQL drivers working. </p>
  
  <p>Again, I needed to use MS SQL drivers and so installed again. With MS SQL drivers installed again - I again failed to connect to PostgreSQL drivers. Though, I did not uninstall MS SQL drivers and checked what was going on. This time around I found that the setup files had got deleted: <code>/usr/lib64/libodbcpsqlS.so</code>. However, replenishing the file did not fix the issue since I did not uninstall MS SQL as in the previous case. </p>
  
  <p>I kept getting the following error message in spite of the file being present with <code>rwx</code> permisions:</p>
  
  <pre><code>[root@localhost lib64]# isql -v STUDENT dsname pwd12345
  [01000][unixODBC][Driver Manager]Can't open lib '/usr/lib64/psqlodbc.so' : file not found
  [ISQL]ERROR: Could not SQLConnect
  [root@localhost lib64]# 
  </code></pre>
  
  <p>Here is a printout of the file permissions:</p>
  
  <pre><code>[root@localhost lib64]# ls -al p*.so
  lrwxrwxrwx. 1 root root     12 Dec  7 09:15 psqlodbc.so -&gt; psqlodbcw.so
  -rwxr-xr-x. 1 root root 519496 Dec  7 09:35 psqlodbcw.so
  </code></pre>
  
  <p>and my <code>odbcinst.ini</code> file looks as follows:</p>
  
  <pre><code>[PostgreSQL]
  Description=ODBC for PostgreSQL
  Driver=/usr/lib/psqlodbc.so
  Driver64=/usr/lib64/psqlodbc.so
  Setup=/usr/lib/libodbcpsqlS.so
  Setup64=/usr/lib64/libodbcpsqlS.so
  FileUsage=1
  UsageCount=4
  </code></pre>
  
  <p>I also referred to this link: <a href="http://mailman.unixodbc.org/pipermail/unixodbc-support/2010-September.txt" rel="nofollow">http://mailman.unixodbc.org/pipermail/unixodbc-support/2010-September.txt</a></p>
  
  <p>Output from running: </p>
  
  <pre><code>[root@localhost bin]# ldd /usr/lib64/psqlodbc.so 
      linux-vdso.so.1 =&gt;  (0x00007fff371ea000)
      libssl.so.10 =&gt; /usr/lib64/libssl.so.10 (0x00007f55f288f000)
      libpq.so.5 =&gt; /usr/lib64/libpq.so.5 (0x00007f55f2667000)
      libpthread.so.0 =&gt; /lib64/libpthread.so.0 (0x00007f55f2449000)
      libodbcinst.so.2 =&gt; not found
      libodbc.so.2 =&gt; not found
      libc.so.6 =&gt; /lib64/libc.so.6 (0x00007f55f20b5000)
      libgssapi_krb5.so.2 =&gt; /lib64/libgssapi_krb5.so.2 (0x00007f55f1e73000)
      libkrb5.so.3 =&gt; /lib64/libkrb5.so.3 (0x00007f55f1b94000)
      libcom_err.so.2 =&gt; /lib64/libcom_err.so.2 (0x00007f55f198f000)
      libk5crypto.so.3 =&gt; /lib64/libk5crypto.so.3 (0x00007f55f1763000)
      libcrypto.so.10 =&gt; /usr/lib64/libcrypto.so.10 (0x00007f55f13c9000)
      libdl.so.2 =&gt; /lib64/libdl.so.2 (0x00007f55f11c4000)
      libz.so.1 =&gt; /lib64/libz.so.1 (0x00007f55f0fae000)
      libcrypt.so.1 =&gt; /lib64/libcrypt.so.1 (0x00007f55f0d77000)
      libldap_r-2.4.so.2 =&gt; /lib64/libldap_r-2.4.so.2 (0x00007f55f0b23000)
      /lib64/ld-linux-x86-64.so.2 (0x0000003d6f600000)
      libkrb5support.so.0 =&gt; /lib64/libkrb5support.so.0 (0x00007f55f0918000)
      libkeyutils.so.1 =&gt; /lib64/libkeyutils.so.1 (0x00007f55f0715000)
      libresolv.so.2 =&gt; /lib64/libresolv.so.2 (0x00007f55f04fa000)
      libfreebl3.so =&gt; /lib64/libfreebl3.so (0x00007f55f0298000)
      liblber-2.4.so.2 =&gt; /lib64/liblber-2.4.so.2 (0x00007f55f0088000)
      libssl3.so =&gt; /usr/lib64/libssl3.so (0x00007f55efe4c000)
      libsmime3.so =&gt; /usr/lib64/libsmime3.so (0x00007f55efc20000)
      libnss3.so =&gt; /usr/lib64/libnss3.so (0x00007f55ef8e3000)
      libnssutil3.so =&gt; /usr/lib64/libnssutil3.so (0x00007f55ef6bd000)
      libplds4.so =&gt; /lib64/libplds4.so (0x00007f55ef4b9000)
      libplc4.so =&gt; /lib64/libplc4.so (0x00007f55ef2b3000)
      libnspr4.so =&gt; /lib64/libnspr4.so (0x00007f55ef076000)
      libsasl2.so.2 =&gt; /usr/lib64/libsasl2.so.2 (0x00007f55eee5c000)
      libselinux.so.1 =&gt; /lib64/libselinux.so.1 (0x00007f55eec3c000)
  </code></pre>
  
  <p>I don't want to uninstall the MS SQL drivers from my Linux machine to get the PostgreSQL drivers to work. I want both drivers to work on Linux.</p>
  
  <p>Craig Ringer suggested to run:</p>
  
  <pre><code>[root@localhost bin]# LD_DEBUG=libs isql -v STUDENT dsname pwd12345
       22029: find library=libodbc.so.1 [0]; searching
       22029:  search path=/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64      (system search path)
       22029:   trying file=/usr/lib64/tls/x86_64/libodbc.so.1
       22029:   trying file=/usr/lib64/tls/libodbc.so.1
       22029:   trying file=/usr/lib64/x86_64/libodbc.so.1
       22029:   trying file=/usr/lib64/libodbc.so.1
       22029: 
       22029: find library=libdl.so.2 [0]; searching
       22029:  search path=/usr/lib64/tls:/usr/lib64      (system search path)
       22029:   trying file=/usr/lib64/tls/libdl.so.2
       22029:   trying file=/usr/lib64/libdl.so.2
       22029:  search cache=/etc/ld.so.cache
       22029:   trying file=/lib64/libdl.so.2
       22029: 
       22029: find library=libpthread.so.0 [0]; searching
       22029:  search path=/usr/lib64/tls:/usr/lib64      (system search path)
       22029:   trying file=/usr/lib64/tls/libpthread.so.0
       22029:   trying file=/usr/lib64/libpthread.so.0
       22029:  search cache=/etc/ld.so.cache
       22029:   trying file=/lib64/libpthread.so.0
       22029: 
       22029: find library=libc.so.6 [0]; searching
       22029:  search path=/usr/lib64/tls:/usr/lib64      (system search path)
       22029:   trying file=/usr/lib64/tls/libc.so.6
       22029:   trying file=/usr/lib64/libc.so.6
       22029:  search cache=/etc/ld.so.cache
       22029:   trying file=/lib64/libc.so.6
       22029: 
       22029: 
       22029: prelink checking: ok
       22029: 
       22029: calling init: /lib64/libpthread.so.0
       22029: 
       22029: 
       22029: calling init: /lib64/libc.so.6
       22029: 
       22029: 
       22029: calling init: /lib64/libdl.so.2
       22029: 
       22029: 
       22029: calling init: /usr/lib64/libodbc.so.1
       22029: 
       22029: 
       22029: initialize program: isql
       22029: 
       22029: 
       22029: transferring control: isql
       22029: 
       22029: find library=libnss_files.so.2 [0]; searching
       22029:  search path=/usr/lib64/tls:/usr/lib64      (system search path)
       22029:   trying file=/usr/lib64/tls/libnss_files.so.2
       22029:   trying file=/usr/lib64/libnss_files.so.2
       22029:  search cache=/etc/ld.so.cache
       22029:   trying file=/lib64/libnss_files.so.2
       22029: 
       22029: 
       22029: calling init: /lib64/libnss_files.so.2
       22029: 
       22029: 
       22029: calling init: /usr/lib64/gconv/UTF-16.so
       22029: 
       22029: find library=libssl.so.10 [0]; searching
       22029:  search path=/usr/lib64/tls:/usr/lib64      (system search path)
       22029:   trying file=/usr/lib64/tls/libssl.so.10
       22029:   trying file=/usr/lib64/libssl.so.10
       22029: 
       22029: find library=libpq.so.5 [0]; searching
       22029:  search path=/usr/lib64/tls:/usr/lib64      (system search path)
       22029:   trying file=/usr/lib64/tls/libpq.so.5
       22029:   trying file=/usr/lib64/libpq.so.5
       22029: 
       22029: find library=libodbcinst.so.2 [0]; searching
       22029:  search path=/usr/lib64/tls:/usr/lib64      (system search path)
       22029:   trying file=/usr/lib64/tls/libodbcinst.so.2
       22029:   trying file=/usr/lib64/libodbcinst.so.2
       22029:  search cache=/etc/ld.so.cache
       22029:  search path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls:/usr/lib64        (system search path)
       22029:   trying file=/lib64/tls/x86_64/libodbcinst.so.2
       22029:   trying file=/lib64/tls/libodbcinst.so.2
       22029:   trying file=/lib64/x86_64/libodbcinst.so.2
       22029:   trying file=/lib64/libodbcinst.so.2
       22029:   trying file=/usr/lib64/tls/libodbcinst.so.2
       22029:   trying file=/usr/lib64/libodbcinst.so.2
       22029: 
  [01000][unixODBC][Driver Manager]Can't open lib '/usr/lib64/psqlodbc.so' : file not found
  [ISQL]ERROR: Could not SQLConnect
       22029: 
       22029: calling fini: isql [0]
       22029: 
       22029: 
       22029: calling fini: /usr/lib64/libodbc.so.1 [0]
       22029: 
       22029: 
       22029: calling fini: /lib64/libdl.so.2 [0]
       22029: 
       22029: 
       22029: calling fini: /lib64/libpthread.so.0 [0]
       22029: 
       22029: 
       22029: calling fini: /lib64/libnss_files.so.2 [0]
       22029: 
       22029: 
       22029: calling fini: /usr/lib64/gconv/UTF-16.so [0]
       22029: 
       22029: 
       22029: calling fini: /lib64/libc.so.6 [0]
       22029: 
  [root@localhost bin]# 
  </code></pre>
  
  <p>John Greene suggested: </p>
  
  <pre><code>[root@localhost bin]# ldd /usr/bin/isql 
      linux-vdso.so.1 =&gt;  (0x00007fff12cf9000)
      libodbc.so.1 =&gt; /usr/lib64/libodbc.so.1 (0x0000003ef0800000)
      libdl.so.2 =&gt; /lib64/libdl.so.2 (0x0000003d6fe00000)
      libpthread.so.0 =&gt; /lib64/libpthread.so.0 (0x0000003d70200000)
      libc.so.6 =&gt; /lib64/libc.so.6 (0x0000003d6fa00000)
      /lib64/ld-linux-x86-64.so.2 (0x0000003d6f600000)
  </code></pre>