Search code examples
coracleappimage

Oracle OCI library fails when packaged in AppImage


The following code sets up an OCI (Oracle Call Interface) environment, which must be done before attempting to connect to a database. It works fine when compiled and linked as a normal program, but when I attempt to package it into an AppImage, OCIEnvCreate() returns OCI_ERROR.

If I set LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib/ the AppImage works as expected. Apparently the library trickery done by the AppImage builder fails somehow on the Oracle libraries. Is there some trick to make them work in an AppImage?

(Setting LD_LIBRARY_PATH isn't a solution, since I'm trying to not have to install the Oracle library on every client.)

Tested on CentOS 8, GCC 8.4.1 and 10.2.1, oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64

#include <oratypes.h>
#include <oci.h>
#include <stdio.h>

int main() {
    OCIEnv        *envhp;
    int status;
    status = OCIEnvCreate((OCIEnv **)&envhp,
            (ub4) OCI_DEFAULT,
            (void  *)0, (void  * (*)(void  *, size_t))0,
            (void  * (*)(void  *, void  *, size_t))0,
            (void (*)(void  *, void  *))0,
            (size_t)0, (void  **)0);
      if (OCI_ERROR == status) {
        printf("Failed: OCIEnvCreate()\n");
      } else if (OCI_SUCCESS == status) {
        printf("Success: OCIEnvCreate()\n");
      } else {
        printf("Other return status '%d' from OCIEnvCreate()\n", status);
      }
}

Solution

  • The appimage builder didn't copy all the OCI shared libraries to the AppImage automatically. Adding each .so file to the linuxdeploy command line with --library /path/to/library.so for each library file fixed the problem. Presumably some .so->.so dependency wasn't resolved by the automatic process.