Page 1 of 4 123 ... LastLast
Results 1 to 15 of 47
  1. #1
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37

    Unanswered: OCCI on AIX with Oracle 9

    I am trying to write a C++ program to access an Oracle database using the OCCI, has anyone here done this ??? I need to ask few questions...

    Thank you

  2. #2
    Join Date
    Aug 2004
    Location
    France
    Posts
    754
    Hi,

    I'm currently developing with OCCI under the Sun Solaris 9 OS (not AIX). I think I may help you. What do you exactly want to know ?

  3. #3
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    Quote Originally Posted by RBARAER
    Hi,

    I'm currently developing with OCCI under the Sun Solaris 9 OS (not AIX). I think I may help you. What do you exactly want to know ?
    Well I have this AIX box and on it there is an Oracle 9i database. I also have gcc vers 3.3.3 on this box.

    I tried to compile a simple Hello World program(Created enviroment and connection) and also the example programs from the Oracle website but no luck. I dont know where to start even. I am a complete newbie to this business.......

    Do I need to install OCCI specially or do I need to configure gcc or what ???

    I have no clue sorry about being such a newb we all have to begin somewhere right ??

  4. #4
    Join Date
    Aug 2004
    Location
    France
    Posts
    754
    All right, I know more than anyone how it is hard to begin with OCCI, for it is all the worst explained in the Oracle doc. I will try to remember what I had to do at the beginning... First of all, you need to link your program to libocci.so, located in the $ORACLE_HOME/lib directory. Don't you see it ? Normal ! There is just a "libocci.so.9.0" (there is what seems to be a shortcut named "libocci.so", but it did not work for me). Make a copy of this file, in the same directory, but name this copy "libocci.so". You'll have to add $ORACLE_HOME/lib to your LD_LIBRARY_PATH environment variable (I don't know if it is the same on AIX), and compile with "-locci". Concerning the header files for your "#include", I don't remember quite well, for I mixed them from different directories... I know some are in $ORACLE_HOME/rdbms/demo, others in $ORACLE_HOME/rdbms/public, but I'm not sure all you need is here. I fear thatif it is not the case, you'll have to search a little by yourself. Then compile with -I$ORACLE_HOME/rdbms/demo, -I... I think that should do it for compiling. Then, to connect, you have to configure a "listener". In order to do this, run $ORACLE_HOME/bin/netca and create a listener. Do not hesitate if you still have questions.

  5. #5
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    omg thank you sooo much for taking the time to explain. This is exactly what I needed ...

    I will get on this and then most likely post some more questions for you very soon....

  6. #6
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    I am just so sorry, I am terribly new to unix programming and all that, used to the idiot-proof compilations at VC++ and C#

  7. #7
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    Okey here is what I get when I try to compile the oocidml.cpp demo file from Oracle:

    Code:
    make -f demo_rdbms.mk occidml
    /bin/make -f /u01/app/oracle/product/9.2.0/rdbms/demo/demo_rdbms.mk buildocci EXE=occidml OBJS=occidml.o
    /usr/bin/xlC -c -q64  -I/u01/app/oracle/product/9.2.0/rdbms/demo -I/u01/app/oracle/product/9.2.0/rdbms/public -I/u01/app/oracle/product/9.2.0/plsql/public -I/u01/app/oracle/product/9.2.0/network/public occidml.cpp
    /usr/bin/xlC: not found
    
    make: 1254-004 The error code from the last command is 1.
    
    Stop.
    make: 1254-004 The error code from the last command is 2.
    
    Stop.

  8. #8
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    I have a folder called: /usr/lpp/xlC

    What is this xlC for ??

  9. #9
    Join Date
    Aug 2004
    Location
    France
    Posts
    754
    Obviously, it tries to compile with xlC (which I don't know), and it does not find it in your /usr/bin directory. I personally compiled using CC. I'm sorry but I did not compile Oracle demos. I began with writing a simple program of mine, just trying to create the environment and the connection. I then added a query, another and so on... I suggest you begin like this, for compile errors will be much easier to spot. Also write your own makefile, for Oracle ones are, in my opinion, simply unreadable. Here is a makefile example for a Test.cpp program. Replace all "/disk01/app/oracle/products/9.2.0.1.0/" with your ORACLE_HOME directory, and it should work. Just cut and paste the text below in a file named "makefile", put it in the same directory as Test.cpp, and run "make -f makefile", or simply "make". Tell me if it works !

    #makefile du fichier Test.cpp
    INCLUDES=-I/disk01/app/oracle/products/9.2.0.1.0/rdbms/demo -I/disk01/app/oracle/products/9.2.0.1.0/rdbms/public -I/disk01/app/oracle/products/9.2.0.1.0/plsql/public -I/disk01/app/oracle/products/9.2.0.1.0/network/public
    CFLAGS= -O -xarch=v9
    LDFLAGS=
    #Dynamic libraries to use : to use libocci.so, write -locci. -lclntsh is also necessary
    LDLIB= -locci -lclntsh
    #Directories where to find *.so
    LDIRS= -L/disk01/app/oracle/products/9.2.0.1.0/lib
    SOURCES=Test.cpp
    OBJECTS=Test.o
    #Your exe
    TARGET=Test
    #The compiler to use
    COMPILER=CC
    #What to do
    all: Test clean

    #clean removes *.o after the exe has been generated, you can change that
    clean:
    rm *.o
    #Generate the .o
    Test.o: Test.cpp
    $(COMPILER) $(CFLAGS) $(INCLUDES) -c Test.cpp -o Test.o
    #Generate the exe
    Test: Test.o
    $(COMPILER) $(CFLAGS) Test.o $(LDIRS) $(LDLIB) $(LDFLAGS) -o $(TARGET)
    Last edited by RBARAER; 08-12-04 at 07:59.

  10. #10
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    Good morning RBARAER

    Here is what I got when I tried to "make -f makefile":
    Code:
    make
    "makefile", line 20: make: 1254-055 Dependency line needs colon or double colon operator.
    "makefile", line 23: make: 1254-055 Dependency line needs colon or double colon operator.
    "makefile", line 26: make: 1254-055 Dependency line needs colon or double colon operator.
    make: 1254-058 Fatal errors encountered -- cannot continue.
    Here are how the lines it is preferring to look like:
    Line 20
    clean:

    Line 23:
    Test.o: Test.cpp

    Line 26
    Test: Test.o

  11. #11
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    I am soo sorry, this was my fault of course, I guess it is too early in the morning....

    I fixed these three lines and now the makefile looks like this:
    Code:
    #Dynamic libraries to use : to use libocci.so, write -locci. -lclntsh is also necessary
    LDLIB= -locci -lclntsh
    #Directories where to find *.so
    LDIRS= -L/u01/app/oracle/product/9.2.0/lib
    SOURCES=Test.cpp
    OBJECTS=Test.o
    #Your exe
    TARGET=Test
    #The compiler to use
    COMPILER=gcc
    #What to do
    all: Test clean
    
    #clean removes *.o after the exe has been generated, you can change that
    clean: rm *.o
    #Generate the .o
    Test.o: Test.cpp
            $(COMPILER) $(CFLAGS) $(INCLUDES) -c Test.cpp -o Test.o
    #Genarate the exe
    Test: Test.o
            $(COMPILER) $(CFLAGS) Test.o $(LDIRS) $(LDLIB) $(LDFLAGS) -o $(TARGET)
    But my error is now this:
    Code:
    gcc -O -xarch=v9 -I/u01/app/oracle/product/9.2.0/rdbms/demo -I/u01/app/oracle/product/9.2.0/rdbms/public -I/u01/app/oracle/product/9.2.0/plsql/public -I/u01/app/oracle/product/9.2.0/network/public -c Test.cpp -o Test.o
    gcc: language arch=v9 not recognized
    gcc: Test.cpp: linker input file unused because linking not done
            gcc -O -xarch=v9 Test.o -L/u01/app/oracle/product/9.2.0/lib -locci -lclntsh  -o Test
    gcc: Test.o: No such file or directory
    make: 1254-004 The error code from the last command is 1.
    
    
    Stop.

  12. #12
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    If I take out the -xarch=v9 in the CFLAGS I get this error:
    make: 1254-002 Cannot find a rule to create target rm from dependencies.
    Stop.

    it is refeering to line:
    clean: rm *.o

  13. #13
    Join Date
    Aug 2004
    Location
    France
    Posts
    754
    rm is an OS command (same as "del" in DOS), maybe it does not work on AIX. Try to replace it with the proper AIX command, or delete the "clean" dependency from the makefile. (and don't refer to it: just put "all: Test")

  14. #14
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    rm is the correct command.....

    I just took it out of all: and will clean it manually...

    Now I have successfully compiled a hello world program while includeing <occi.h>

    Right now I am writing a little program to create a connection.... Will post back soon

  15. #15
    Join Date
    Aug 2004
    Location
    Iceland
    Posts
    37
    Alright here we go....

    This is the program I have:
    Code:
    #include <iostream>
    #include <string>
    #include <occi.h>
    
    using namespace oracle::occi;
    using namespace std;
    
    class occiBK
    {
            private:
            Environment *env;
            Connection *conn;
            Statement *stmt;
    
            public:
    
            occiBK (string user, string passwd, string db)
            {
                    env = Environment::createEnvironment (Environment::DEFAULT);
                    conn = env->createConnection( user, passwd, db);
            }
            ~occiBK ()
            {
                    env->terminateConnection(conn);
                    Environment::terminateEnvironment (env);
            }
    };
    
    
    int main(void)
    {
            string user="*****";
            string passwd="*****";
            string db="****";
    
            occiBK *demo = new occiBK (user, passwd, db);
            cout << "Creation Successful" << endl;
            delete (demo);
            cout << "Deletion Successful" << endl;
    
    }
    And here is the error:
    Code:
    c++ -O  Test.o -L/u01/app/oracle/product/9.2.0/lib -locci -lclntsh  -o Test
    ld: 0711-317 ERROR: Undefined symbol: .oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned long), void* (*)(void*, void*, unsigned long), void (*)(void*, void*))
    ld: 0711-317 ERROR: Undefined symbol: .oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)
    ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
    collect2: ld returned 8 exit status
    make: 1254-004 The error code from the last command is 1.
    
    Stop.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •