5

I'm trying to run the following test program on Ubuntu to connect to an oracle database using the instant client OCCI library.

#include <iostream>
#include <occi.h>

using namespace oracle::occi;
int main() {

    Environment *env = Environment::createEnvironment(Environment::DEFAULT);
    Connection *conn = env->createConnection( "user", "1234" ); 
    env->terminateConnection(conn);
    Environment::terminateEnvironment(env);

}

There are no errors when compiling

g++ main.cpp -L ~/instantclient_12_2 -locci -lclntsh -I ~/instantclient_12_2/sdk/include

But when running I get

terminate called after throwing an instance of 'oracle::occi::SQLException'
  what():  ORA-24960: the attribute  OCI_ATTR_USERNAME is greater than the maximum allowable length of 255
Aborted

I'm running Ubuntu 16.04, gcc 5.4.0 and I get the same result with instant client 11.2 and 12.2.

This has been asked before: https://stackoverflow.com/questions/40022118/ora-24960-the-attribute-oci-attr-username-is-greater-than-the-maximum but the answer is not applicable to linux (or I'm missing the point).

Any help would be appreciated.

Community
  • 1
  • 1
thepotter
  • 71
  • 1
  • 5

3 Answers3

2

Solved the problem by reverting to an older compiler.

$ sudo apt-get install g++-4.8
$ g++-4.8 main.cpp -L ~/instantclient_12_2 -locci -lclntsh -I ~/instantclient_12_2/sdk/include

Perhaps the latest compiler and libraries is incompatible with those used to build the OCCI libraries.

thepotter
  • 71
  • 1
  • 5
  • Any news if a solution could be found using gcc 5.4.0? I'm facing [similar issues](https://stackoverflow.com/questions/52072954/compatibility-issues-with-oracle-occi-and-g-7-1). – andreee Aug 29 '18 at 08:34
  • 1
    Do you know what is wrong with newer versions of the compiler? – Ammar Hussein Aug 15 '19 at 07:24
2

Also help to use -D_GLIBCXX_USE_CXX11_ABI=0 flag.

Laszlo
  • 21
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 04 '22 at 12:24
1

If you are using CMake

1) Add this line on your CMakeLists.txt to specify the compiler to use

SET(CMAKE_CXX_COMPILER /usr/bin/g++-4.8)

P.S You may have to install g++-4.8

(apt-get install g++-4.8)
Victor Mwenda
  • 1,677
  • 17
  • 16