1 Reply Latest reply on Apr 1, 2019 7:11 AM by 3782129

    Undefined symbols for architecture x86_64: "oracle::occi::Environment::..."

    3782129

      Hi there,

       

      Using Xcode, I am trying to write a dummy C++ program to connect to a database.

       

      int main(int argc, const char * argv[]) {

          // Create an environment

          oracle::occi::Environment *env = oracle::occi::Environment::createEnvironment();

          {

              oracle::occi::Connection *conn = env->createConnection("usr", "pwd", "db");

              oracle::occi::Statement *stmt = conn->createStatement("SELECT mycolumn FROM mytable");

              oracle::occi::ResultSet *rs = stmt->executeQuery();

              rs->next();

              oracle::occi::Number b = rs->getNumber(1);

              std::cout << "Number of sessions : " << b.operator int();

              stmt->closeResultSet(rs);

              conn->terminateStatement(stmt);

              env->terminateConnection(conn);

          }

          // Terminate environment

          oracle::occi::Environment::terminateEnvironment(env);

      }

       

      Compilation step fails with with a link issue

      Undefined symbols for architecture x86_64:

        "oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned long), void* (*)(void*, void*, unsigned long), void (*)(void*, void*))", referenced from:

            _main in main.o

        "oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)", referenced from:

            _main in main.o

      ld: symbol(s) not found for architecture x86_64

      clang: error: linker command failed with exit code 1 (use -v to see invocation)

       

      I a added the path to the libraries of instantclient 12.2 to env variable DYLD_LIBRARY_PATH but it did not help.

      This path was added to the library search paths of Xcode.

      Would you have an idea how to solve this issue?

       

      Thanks a lot in advance,

      A C++ beginner

        • 1. Re: Undefined symbols for architecture x86_64: "oracle::occi::Environment::..."
          3782129

          Edit: I also just realize I have two warings when compiling:

           

          warning: skipping file '/Users/username/Library/Oracle/instantclient_12_2/libocci.dylib.12.1' (unexpected file type 'text.man' in Frameworks & Libraries build phase)

          warning: skipping file '/Users/username/Library/Oracle/instantclient_12_2/libclntsh.dylib.12.1' (unexpected file type 'text.man' in Frameworks & Libraries build phase)

           

          which are the two libraries I linked at build phase.

           

          Had to add DYLD_LIBRARY_PATH to env vars in product>scheme>edit scheme.

          Also add -locci and -lclntsh to other linker flags in build settings.