News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Code::blocks Oracle OCI/OCCI?

Started by GalaG, April 04, 2009, 10:46:43 PM

Previous topic - Next topic

GalaG

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.

mandrav

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...

GalaG

Quote from: mandrav 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.

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.

mandrav

Quote from: GalaG on April 05, 2009, 06:41:18 AM
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...

GalaG

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,

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.
Be patient!
This bug will be fixed soon...

GalaG

#6
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:

#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:

-------------- 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

MortenMacFly

Quote from: GalaG on May 19, 2009, 01:15:14 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

GalaG

here it is:

-------------- 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


MortenMacFly

Check:
Quote from: GalaG on May 19, 2009, 03:34:56 PM

..\..\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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

GalaG

yes, her it is:
------------- 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

MortenMacFly

Quote from: GalaG on May 19, 2009, 04:05:19 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

GalaG

Damn, no change... sure I'm not missing some flags?

-------------- 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

MortenMacFly

Quote from: GalaG on May 19, 2009, 09:38: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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

GalaG

I found a few in the oraocci10.lib

like this fragment:

oraocci10.dll:
00000000 I .idata$4
00000000 I .idata$5
00000000 I .idata$6
00000000 T .text
00000000 T ??0BatchSQLException@occi@oracle@@AAE@PAVSQLExceptionImpl@12@@Z
00000000 I __imp_??0BatchSQLException@occi@oracle@@AAE@PAVSQLExceptionImpl@12@@Z

oraocci10.dll:
00000000 I .idata$4
00000000 I .idata$5
00000000 I .idata$6
00000000 T .text
00000000 T ??0BatchSQLException@occi@oracle@@QAE@ABV012@@Z
00000000 I __imp_??0BatchSQLException@occi@oracle@@QAE@ABV012@@Z

oraocci10.dll:
00000000 I .idata$4
00000000 I .idata$5
00000000 I .idata$6
00000000 T .text
00000000 T ??0BatchSQLExceptionImpl@occi@oracle@@QAE@PAX0@Z
00000000 I __imp_??0BatchSQLExceptionImpl@occi@oracle@@QAE@PAX0@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.