Solved

Creating a shared library in AIX for Oracle to use

Posted on 2004-09-08
5
710 Views
Last Modified: 2008-02-01
A while back I wrote some code in C for Windows NT. I compiled this code in NT and created a dll. Then I was able to invoke this dll through PL/SQL after creating a user library in Oracle. This code consists of 2 cpp files and 2 header files. I have to link this code to an external library.

Now I need to take this code and compile it in AIX. I looked at the Oracle makefiles that they suggest we use for compiling . I guess in AIX the equivalent of a Windows NT dll is a shared library. How can I modify the Oracle provided makefiles to create my shared library? Where in the makefiles do I include my external library that I need to link my code to? In addition I need to add a path where my include files reside. Where do I do this?

Thanks
Silvia
0
Comment
Question by:SilviaMacke
5 Comments
 
LVL 47

Accepted Solution

by:
schwertner earned 250 total points
ID: 12006482
AIX handles shared libraries a bit differently than many other UNIX platforms. If the "shr.o" object exists in a library, then that library will be dynamically linked at run time.  
 
To check if a library includes the "shr.o" object do the following:  
 
1. Change locations to the "lib" directory  
 
     % cd $ORACLE_HOME/lib  
 
2. Verify that the "shr.o" object exists  
 
     % /usr/ccs/bin/nm <library_name>|grep shr.o  
 
     For example:  
 
          % /usr/ccs/bin/nm libclntsh.a|grep shr.o  
          libclntsh.a[shr.o]:  
 
3. Check to see if an executable has been linked with a shared library  
 
     % /usr/sbin/dump -Hv <executable>  
 
     For example, here is the output from the svrmgrl executable in 8.0.4:  
 
     % cd $ORACLE_HOME/bin  
     % /usr/sbin/dump -Hv svrmgrl  
 
     svrmgrl:  
 
             ***Loader Section***  
                 =           Loader Header Information  
     VERSION#         #SYMtableENT     #RELOCent        LENidSTR  
     0x00000001       0x000000d2       0x00002709       0x000000b3  
 
     #IMPfilID        OFFidSTR         LENstrTBL        OFFstrTBL  
     0x00000006       0x0001e83c       0x000003c0       0x0001e8ef  
 
 
                        ***Import File Strings***  
     INDEX  PATH  BASE                MEMBER  
     0  
/u01/app/oracle/product/8.0.4/lib/:/u01/app/oracle/product/8.0.4/rdbms/li  
     b:/usr/lib:/lib  
     1                      libc_r.a         shr.o  
     2                      libpthreads.a       shr.o  
     3       libc_r.a            aio.o  
     4                      libodm.a            shr.o  
     5                      libclntsh.a         shr.o  
 
   
     NOTE:  "libclntsh.a" (BASE) contains "shr.o" (MEMBER), and  
            therefore is a dynamically linked library.  At run time,  
            the path specified in INDEX 0 will be searched for the  
            "libclntsh.a" library, and if not found, it will then  
            check the environment variable LIBPATH for its location.  
 
   
AIX dynamically linked libraries may contain an ".so" or ".a" extension.  The  
existence of the shared object (shr.o) in the library determines whether it is  
dynamically or statically linked.

0
 

Author Comment

by:SilviaMacke
ID: 12006536
That sounds good, however it does not answer my question.

I have two source files: test1.cpp
                                   test2.cpp
Two header files: test1.h
                          test2.h

The file test1.cpp contains definition a class and its functions
The file test2.cpp instantiates the class from test1.cpp and it creates the functions that I want to export.

When compiling the source code, I need to link this code to another library and inlcude a path.
How do I do this ? Can I use the Oracle make files?

I need to compile this as a Unix Shared Library
0
 
LVL 22

Assisted Solution

by:earth man2
earth man2 earned 250 total points
ID: 12006928
can you use $ORACLE_HOME/rdbms/demo/demo_rdbms.mk extproc_no_context | extproc_with_context
or extproc_nocallback and extproc_callback
#    A single external procedure demo whose 3GL routines do not use the
#    "with context" argument:
#
#    make -f demo_rdbms.mk extproc_no_context SHARED_LIBNAME=libname
#                                             OBJS="demo.o ..."
mo1.o epdemo2.o"
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
select only modified column name  based on the status 15 47
report returning null 21 80
Oracle RAC 12c 8 60
Difference in number of minutes between 2 timestamps 16 39
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now