User forums > Help

Code::blocks Oracle OCI/OCCI?

<< < (2/4) > >>

mandrav:
Just add 'oci' in link libraries of your project. If there is no 'liboci.a' available, gcc will link to the 'oci.dll' which is. No special flags or anything.

GalaG:
Hello again, just got back to this project and, still, unable to link a simple test, here is the steps I did:
(using gcc and not borland)

!) used mingw's util 'reimp' to convert the .lib (msvc) file of occi, oci to a .a files.
2) added this files to the linker tab of the build options.
3) tried to build this main.cpp:

--- Code: ---#include <iostream>
#include <occi.h>
using namespace oracle::occi;
using namespace std;

class  occidml
{
  private:

  Environment *env;
  Connection *conn;
  Statement *stmt;
  public:

  occidml (string user, string passwd, string db)
  {
    env = Environment::createEnvironment (Environment::DEFAULT);
    conn = env->createConnection (user, passwd, db);
  }

  ~occidml ()
  {
    env->terminateConnection (conn);
    Environment::terminateEnvironment (env);
  }
};

int main()
{
    string user = "HR";
  string passwd = "HR";
  string db = "localhost:1521/XE";

  try
  {
    cout << "occidml - Exhibiting simple insert, delete & update operations"
      << endl;
    occidml *demo = new occidml (user, passwd, db);

    delete (demo);
    cout << "occidml - done" << endl;
  }
  catch (SQLException ea)
  {
    cerr << "Error running the demo: " << ea.getMessage () << endl;
  }
}

--- End code ---

and got:

--- Code: ----------------- Build: Debug in OCCITest ---------------

Linking console executable: bin\Debug\OCCITest.exe
obj\Debug\main.o: In function `main':
C:/codeblocksWS/OCCITest/main.cpp:43: undefined reference to `oracle::occi::SQLException::SQLException(oracle::occi::SQLException const&)'
C:/codeblocksWS/OCCITest/main.cpp:45: undefined reference to `oracle::occi::SQLException::getMessage() const'
C:/codeblocksWS/OCCITest/main.cpp:45: undefined reference to `oracle::occi::SQLException::~SQLException()'
C:/codeblocksWS/OCCITest/main.cpp:45: undefined reference to `oracle::occi::SQLException::~SQLException()'
obj\Debug\main.o: In function `ZN7occidmlC1ESsSsSs':
C:/codeblocksWS/OCCITest/main.cpp:(.text$_ZN7occidmlD1Ev[occidml::~occidml()]+0x2f): undefined reference to `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)'
C:/codeblocksWS/OCCITest/main.cpp:(.text$_ZN7occidmlC1ESsSsSs[occidml::occidml(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x3a): undefined reference to `oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned int), void* (*)(void*, void*, unsigned int), void (*)(void*, void*))'
collect2: ld returned 1 exit status\

--- End code ---

any ideas?
also, how exactly and where exactly can I link directly to the oracocci10.dll file? tried putting the file name (with path) in the
'build options > linker setting > other linker options' text box, and the compiler/linker didn't run.

Thanks a lot.
Gal

MortenMacFly:

--- Quote from: GalaG on May 19, 2009, 01:15:14 pm ---any ideas?

--- End quote ---
Post the full compile log, please (see my sig how to do that).

GalaG:
here it is:

--- Code: ----------------- Build: Debug in OCCITest ---------------

mingw32-g++.exe -L..\..\XEClient\oci\lib\gcc  -o bin\Debug\OCCITest.exe obj\Debug\main.o    ..\..\XEClient\oci\lib\gcc\liboraocci10d.a
obj\Debug\main.o: In function `main':
C:/codeblocksWS/OCCITest/main.cpp:43: undefined reference to `oracle::occi::SQLException::SQLException(oracle::occi::SQLException const&)'
C:/codeblocksWS/OCCITest/main.cpp:45: undefined reference to `oracle::occi::SQLException::getMessage() const'
C:/codeblocksWS/OCCITest/main.cpp:45: undefined reference to `oracle::occi::SQLException::~SQLException()'
C:/codeblocksWS/OCCITest/main.cpp:45: undefined reference to `oracle::occi::SQLException::~SQLException()'
obj\Debug\main.o: In function `ZN7occidmlC1ESsSsSs':
C:/codeblocksWS/OCCITest/main.cpp:(.text$_ZN7occidmlD1Ev[occidml::~occidml()]+0x2f): undefined reference to `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)'
C:/codeblocksWS/OCCITest/main.cpp:(.text$_ZN7occidmlC1ESsSsSs[occidml::occidml(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x3a): undefined reference to `oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned int), void* (*)(void*, void*, unsigned int), void (*)(void*, void*))'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
6 errors, 0 warnings
 

--- End code ---

MortenMacFly:
Check:

--- Quote from: GalaG on May 19, 2009, 03:34:56 pm ---
--- Code: ---..\..\XEClient\oci\lib\gcc\liboraocci10d.a

--- End code ---

--- End quote ---
...with the symbol table plugin if the symbols missing are defined. Probably some name (de-)mangeling is needed.
...can you, post a re-build log? Your log only shows the linking step...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version