filosofisto
filosofisto

Reputation: 107

OCCI linkage: Undefined symbols

I have been working in a solution with Oracle database access and C/C++. I'm using OCCI but we are in trouble to link in Solaris 11. Solution works "like a charm" in Linux (OpenSUSE and Mint), but doesn't in Solaris 11.

Here environment informations:

  1. I downloaded instantclient_11_2 (sun sparc version) and unpacked it in a Solaris folder
  2. I created symbolic links to libclntsh.so.11.1 called libclntsh.so, and for libocci.so.11.1 called libocci.so. Bellow a "ls -l" showing files:

    • -rwxrwxr-x 1 f780333 desenv 23792 Aug 22 2013 adrci
    • -rw-rw-r-- 1 f780333 desenv 414 Aug 22 2013 BASIC_README
    • -rwxrwxr-x 1 f780333 desenv 41464 Aug 22 2013 genezi
    • lrwxrwxrwx 1 f780333 desenv 17 Apr 5 14:21 libclntsh.so -> libclntsh.so.11.1
    • -rwxrwxr-x 1 f780333 desenv 50268448 Aug 22 2013 libclntsh.so.11.1
    • -r-xr-xr-x 1 f780333 desenv 8653320 Aug 22 2013 libnnz11.so
    • lrwxrwxrwx 1 f780333 desenv 15 Apr 5 14:22 libocci.so -> libocci.so.11.1
    • -rwxrwxr-x 1 f780333 desenv 1545008 Aug 22 2013 libocci.so.11.1
    • -rwxrwxr-x 1 f780333 desenv 118735824 Aug 22 2013 libociei.so
    • -r-xr-xr-x 1 f780333 desenv 121800 Aug 22 2013 libocijdbc11.so
    • -r--r--r-- 1 f780333 desenv 2091135 Aug 22 2013 ojdbc5.jar
    • -r--r--r-- 1 f780333 desenv 2739616 Aug 22 2013 ojdbc6.jar
    • drwxrwxr-x 4 f780333 desenv 7 Aug 22 2013 sdk
    • -rwxrwxr-x 1 f780333 desenv 177680 Aug 22 2013 uidrvci
    • -rw-rw-r-- 1 f780333 desenv 66779 Aug 22 2013 xstreams.jar
  3. I created another folder that contens symbolic links to important needs libraries from Solaris.I am linking project with options -m64 -lCstd -lrt -lsocket. m64 to force 64bits, it was necessary. Cstd, rt and socket due the fact that these libraries are used indirectly.

  4. I am using Netbeans and compile remotely in Solaris 11

Compilation works fine. Compilation command patterns is showed bellow:

g++ -m64 -c -g -I/home/f780333/paineldaemon/lib/indra_clib/include -I/home/f780333/paineldaemon/lib/instantclient_11_2/sdk/include -std=c++98 -MMD -MP -MF "build/Debug/GNU-Solaris-Sparc/main.o.d" -o build/Debug/GNU-Solaris-Sparc/main.o main.cpp

/home/f780333/paineldaemon/lib/indra_clib/include is a folder with a static library used by program. This library is mine and is necessary for project.

/home/f780333/paineldaemon/lib/instantclient_11_2/sdk/include is a folder from instantclient sdk, that includes *.h from OCCI.

But when linkage process starts, all head pain starts too:

(first) Linkage command:

g++ -o <all files here> -L/home/f780333/paineldaemon/lib/sun -L/home/f780333/paineldaemon/lib -L/home/f780333/paineldaemon/lib/instantclient_11_2 -R'/home/f780333/paineldaemon/lib/sun' -R'/home/f780333/paineldaemon/lib' -R'/home/f780333/paineldaemon/lib/instantclient_11_2' -lclntsh -locci /home/f780333/paineldaemon/lib/libindra_clib.a -m64 -lCstd -lrt -lsocket

And finally the linker ERROR MESSAGE:

Undefined           first referenced
  symbol                in file
oracle::occi::Date::~Date()         build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Date::Date()          build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Number::operator=(oracle::occi::Number const&) build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Number::Number(double) build/Debug/GNU-Solaris-Sparc/MessageBuilder.o
oracle::occi::Number::Number(long)  build/Debug/GNU-Solaris-Sparc/MessageBuilder.o
oracle::occi::Number::Number()      build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Number::~Number()     build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned long), void* (*)(void*, void*, unsigned long), void (*)(void*, void*)) build/Debug/GNU-Solaris-Sparc/DatabaseOperation.o
oracle::occi::Date::operator=(oracle::occi::Date const&) build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*) build/Debug/GNU-Solaris-Sparc/DatabaseOperation.o
oracle::occi::Date::Date(oracle::occi::Environment const*, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) build/Debug/GNU-Solaris-Sparc/MessageBuilder.o
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
gmake[2]: *** [dist/Debug/GNU-Solaris-Sparc/paineldaemon] Error 1
gmake[2]: Leaving directory `/home/f780333/.netbeans/remote/172.16.160.172/sylvia-Linux-x86_64/home/eduardo/Indra/Cartoes/repo/paineldaemon'
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory `/home/f780333/.netbeans/remote/172.16.160.172/sylvia-Linux-x86_64/home/eduardo/Indra/Cartoes/repo/paineldaemon'
gmake: *** [.build-impl] Error 2

I am crazy with this problem, any help will be much apreciate.

Upvotes: 0

Views: 671

Answers (1)

Andrew Henle
Andrew Henle

Reputation: 1

In my experience, OCCI has always been built for Solaris by using the Solaris Studio compiler.

You can't link an executable that uses CC-built code using g++, unless you can somehow coerce g++ to link in both the C++ run time libraries libCrun.so and libCstd.so along with the proper C++ run-time startup code, the same as Solaris Studio's CC does. That's probably not impossible, but it would be easier to just invoke ld directly and link the binary yourself.

And you can't compile C++ source code with g++ to match the name-mangling scheme used by Solaris Studio CC. (unless the code was built with a later version of CC and it used command-line arguments to produce g++-compatible name-mangling, among many other compatibility requirements, which in my experience OCCI never has been...)

In short, you need to use Solaris Studio's CC compiler to use OCCI on Solaris.

Upvotes: 2

Related Questions