Author Topic: Code::blocks Oracle OCI/OCCI?  (Read 19479 times)

Offline GalaG

  • Multiple posting newcomer
  • *
  • Posts: 12
Code::blocks Oracle OCI/OCCI?
« on: April 04, 2009, 10:46:43 pm »
has anyone had success accessing Oracle 9i/10i using code::blocks ether with mingw or Borland command line?

I'm having a major headache with this, I can make (mingw) .a or (Blorland) .lib
files from the oci.dll file but, other the that... I'm knda lost.

I know its a C++/Code::blocks border like question, but please, help!!  :(

Thanks.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4305
    • Code::Blocks IDE
Re: Code::blocks Oracle OCI/OCCI?
« Reply #1 on: April 05, 2009, 12:32:07 am »
Yes, it works fine. Just link to the msvc dll directly, no need to create an import library (.a) from it.
Be patient!
This bug will be fixed soon...

Offline GalaG

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Re: Code::blocks Oracle OCI/OCCI?
« Reply #2 on: April 05, 2009, 06:41:18 am »
Yes, it works fine. Just link to the msvc dll directly, no need to create an import library (.a) from it.

first of all, thanks  :D

but still, I got a few small questions:
1) I'm using Borland C++, so I have to download MSVC++, right? if so what exactly?
2) how exactly do you link dll files directly in code::blocks? because I need to add oci.dll also, right?
3) what flags should I use in the compiler/linker? I know, it's kinda noob of me...

Thanks for all your help.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4305
    • Code::Blocks IDE
Re: Code::blocks Oracle OCI/OCCI?
« Reply #3 on: April 05, 2009, 08:15:12 pm »
but still, I got a few small questions:

If you use gcc, everything Just Works. For borland I can't say much.
Be patient!
This bug will be fixed soon...

Offline GalaG

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Code::blocks Oracle OCI/OCCI?
« Reply #4 on: April 06, 2009, 08:52:19 am »
Ok, so what flag do you use with GCC? and how do you use the DLLs directly?
I can work the transition to Borland later, just need to get something to work.

Thanks,

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4305
    • Code::Blocks IDE
Re: Code::blocks Oracle OCI/OCCI?
« Reply #5 on: April 06, 2009, 09:53:07 am »
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.
Be patient!
This bug will be fixed soon...

Offline GalaG

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Code::blocks Oracle OCI/OCCI?
« Reply #6 on: May 19, 2009, 01:15:14 pm »
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: [Select]
#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;
  }
}

and got:
Code: [Select]
-------------- 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\

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
« Last Edit: May 19, 2009, 01:37:01 pm by GalaG »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9609
Re: Code::blocks Oracle OCI/OCCI?
« Reply #7 on: May 19, 2009, 03:15:16 pm »
any ideas?
Post the full compile log, please (see my sig how to do that).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline GalaG

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Code::blocks Oracle OCI/OCCI?
« Reply #8 on: May 19, 2009, 03:34:56 pm »
here it is:
Code: [Select]
-------------- 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
 

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9609
Re: Code::blocks Oracle OCI/OCCI?
« Reply #9 on: May 19, 2009, 03:50:05 pm »
Check:
Code: [Select]
..\..\XEClient\oci\lib\gcc\liboraocci10d.a
...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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline GalaG

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Code::blocks Oracle OCI/OCCI?
« Reply #10 on: May 19, 2009, 04:05:19 pm »
yes, her it is:
Code: [Select]
------------- Build: Debug in OCCITest ---------------

mingw32-g++.exe -Wall -fexceptions  -g    -I..\..\XEClient\oci\include  -c C:\codeblocksWS\OCCITest\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -L..\..\XEClient\oci\lib\gcc  -o bin\Debug\OCCITest.exe obj\Debug\main.o    ..\..\XEClient\oci\lib\gcc\liboraocci10.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, 1 seconds)
6 errors, 0 warnings

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9609
Re: Code::blocks Oracle OCI/OCCI?
« Reply #11 on: May 19, 2009, 08:31:07 pm »
yes, her it is:
OK - nothing wrong with that.

Please check the symbols as said in the previous post and also try to link against the MS libs directly. This should work just fine with GCC. GCC can handle such. Maybe the conversion process you did failed.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline GalaG

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Code::blocks Oracle OCI/OCCI?
« Reply #12 on: May 19, 2009, 09:38:38 pm »
Damn, no change... sure I'm not missing some flags?
Code: [Select]
-------------- Build: Debug in OCCITest ---------------

mingw32-g++.exe -Wall -fexceptions  -g    -I..\..\XEClient\oci\include  -c C:\codeblocksWS\OCCITest\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -L..\..\XEClient\oci\lib\gcc  -o bin\Debug\OCCITest.exe obj\Debug\main.o    ..\..\XEClient\oci\lib\msvc\oraocci10.lib ..\..\XEClient\oci\lib\msvc\oci.lib ..\..\XEClient\oci\lib\msvc\ociw32.lib
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, 2 seconds)
6 errors, 0 warnings

gee, what's the problem here? I really don't understand this...
still, any ideas?
Gal

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9609
Re: Code::blocks Oracle OCI/OCCI?
« Reply #13 on: May 19, 2009, 09:50:38 pm »
still, any ideas?
I told you what to do...Check the symbols with the symbols tables plugin. Did you?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline GalaG

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Code::blocks Oracle OCI/OCCI?
« Reply #14 on: May 19, 2009, 10:14:00 pm »
I found a few in the oraocci10.lib

like this fragment:
Code: [Select]
oraocci10.dll:
00000000 I .idata$4
00000000 I .idata$5
00000000 I .idata$6
00000000 T .text
00000000 T [email protected]@[email protected]@[email protected]@[email protected]@Z
00000000 I [email protected]@[email protected]@[email protected]@[email protected]@Z

oraocci10.dll:
00000000 I .idata$4
00000000 I .idata$5
00000000 I .idata$6
00000000 T .text
00000000 T [email protected]@[email protected]@[email protected]@@Z
00000000 I [email protected]@[email protected]@[email protected]@@Z

oraocci10.dll:
00000000 I .idata$4
00000000 I .idata$5
00000000 I .idata$6
00000000 T .text
00000000 T [email protected]@[email protected]@[email protected]@Z
00000000 I __imp[email protected]@[email protected]@[email protected]@Z

so why can't the linker see them?
thanks for the patience,
Gal

PS: the 'occi....Environment' is also present in the same file.