Skip to content

Instantly share code, notes, and snippets.

@Shulyaka
Last active November 20, 2025 11:46
Show Gist options
  • Select an option

  • Save Shulyaka/94ce723bc45e97e5659b6da7e4b6b871 to your computer and use it in GitHub Desktop.

Select an option

Save Shulyaka/94ce723bc45e97e5659b6da7e4b6b871 to your computer and use it in GitHub Desktop.
Oracle client install on Ubuntu

Oracle client installation on Ubuntu

This guide covers some tweaks that are needed to install oracle client (full client, not instant) to Ubuntu. Oracle does not support Ubuntu and installation does not work out of the box, however it is still possible to do it with a couple workarounds.

Note: this is not about the instant client. For instant client, read other guides, typically involving conversion of rpm packages into deb.

TL/DR

  1. Run the installer. It will warn you that the OS is not supported. You can ignore this warning and continue.
  2. The installer will give you an error. Once it does, go to $ORACLE_HOME/lib/ and create new compat_resolv.c file like this:
#define _GNU_SOURCE
#include <resolv.h>
#include <arpa/nameser.h>

int __res_nsearch(res_state statp, const char *dname, int class, int type,
                  unsigned char *answer, int anslen) {
    return res_nsearch(statp, dname, class, type, answer, anslen);
}

int __dn_expand(const unsigned char *msg, const unsigned char *eom,
                const unsigned char *src, char *dest, int space) {
    return dn_expand(msg, eom, src, dest, space);
}

int __dn_skipname(const unsigned char *comp_dn, const unsigned char *eom) {
    return dn_skipname(comp_dn, eom);
}
  1. Compile the file with gcc -fPIC -shared -o libresolv_compat.so compat_resolv.c -lresolv
  2. Open $ORACLE_HOME/bin/orald, find the following lines at the start of the code:
if [ -z "$BASH_VERSION" -o -n "$ORALD_USE_GCC" ] ; then
  exec gcc "$@"
  exit 1
fi

And add -L/usr/lib/x86_64-linux-gnu -fno-PIE -no-pie -Wl,--copy-dt-needed-entries -Wl,--no-as-needed -lresolv_compat between exec and "$@":

if [ -z "$BASH_VERSION" -o -n "$ORALD_USE_GCC" ] ; then
  exec gcc -L/usr/lib/x86_64-linux-gnu -fno-PIE -no-pie -Wl,--copy-dt-needed-entries -Wl,--no-as-needed -lresolv_compat "$@"
  exit 1
fi
  1. Save the file, then go back to the installer and hit "Repeat", now it should complete successfully.

Explanation

Oracle’s build scripts assume the RHEL/Oracle Linux toolchain: libpthread_nonshared.a lives in /usr/lib64, gcc defaults to non-PIE links, and glibc still exports the private resolver symbols (__res_nsearch, __dn_expand, __dn_skipname). Ubuntu’s layout differs: the pthread archive is under x86_64-linux-gnu, gcc enables PIE by default, and glibc ≥2.34 hides those resolver internals, so Oracle’s precompiled objects can’t link out of the box.

To make the link succeed on Ubuntu we:

  • Added -L/usr/lib/x86_64-linux-gnu so ld could see libpthread_nonshared.a.
  • Disabled PIE hardening (-fno-PIE -no-pie) to satisfy Oracle’s non-PIC static libraries.
  • Forced dependent libs to stay on the command line despite Ubuntu’s --as-needed default (-Wl,--no-as-needed, -Wl,--copy-dt-needed-entries).
  • Implemented a small resolver shim defining __res_nsearch, __dn_expand, and __dn_skipname, compiled it, and linked the resulting object so libclntsh.so could resolve those now-hidden glibc symbols.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment