need help in working with shared libraries on hpux


 
Thread Tools Search this Thread
Operating Systems HP-UX need help in working with shared libraries on hpux
# 1  
Old 01-13-2007
need help in working with shared libraries on hpux

hi,
i am having problem loading multiple shared libraries. if i load, make call to exposed method and then unload them, everything workds fine, but i have to keep the loaded images in memory,

i am uploading the prog. as loader.zip, it contains

loader - loader.c which loads c++ shared libraries service1.sl, service2.sl and service3.sl into memory and initilises them

support - a c++ archive library which contains the common support needed for all the services, the loader makes call to a exposed method in support.cpp, HookFun namely..

support.h has a macro defines as EXT_INTERFACE which is smart, when a service says EXT_INTERFACE('servicename'), it expands to something like this

long interface(){
servicename serviceinstance;
servicename.CallService();
}

and the HookFun makes and instance of support class which inturn calls interface(), where an instance the required service is created.

services/service* - services, shared libraries build using the support archive, and loaded by the loader

problem:
case 1)
when i load service1, make a call to initilize the service and then unload it, load service 2 make a call and then unload it, ....

everything is fine.

case 2) if i load service1, make a call to initilize the service (dont unload it), load service 2 make a call to initilize it, but this time service 1 is getting initilized again, service 1 is initilized as many services are there..

(my requirement is that i have to keep all the serivces in mermory at the same time)

output for first case:

The address of the loaded function is 2139010832
the buffer content is service1.sl
got addre for proc and it is 2138878086
Dispatch function called with name service1.sl
Support initilizing
Initilizing class service 1
Service called for service1
The address of the loaded function is 2139010832
the buffer content is service2.sl
got addre for proc and it is 2138878070
Dispatch function called with name service2.sl
Support initilizing
Initilizing class service 2
Service called for service 2
The address of the loaded function is 2139010832
the buffer content is service3.sl
got addre for proc and it is 2138878086
Dispatch function called with name service3.sl
Support initilizing
Initilizing class service 3
Service called for service 3

output for second case: (removed shl_unload)
The address of the loaded function is 2139010832
the buffer content is service1.sl
got addre for proc and it is 2138878086
Dispatch function called with name service1.sl
Support initilizing
Initilizing class service 1
Service called for service1
The address of the loaded function is 2139012144
the buffer content is service2.sl
got addre for proc and it is 2139003802
Dispatch function called with name service2.sl
Support initilizing
Initilizing class service 1
Service called for service1
The address of the loaded function is 2139012472
the buffer content is service3.sl
got addre for proc and it is 2139004250
Dispatch function called with name service3.sl
Support initilizing
Initilizing class service 1
Service called for service1

the code i have attached is very simple, please let me know where i am going wrong.. i am executing the program on hpux 10.0 machine and it is patches properly.

thankx in advance
# 2  
Old 02-08-2007
Are you explicitly exporting your symbols from the shared libraries and ensuring all other symbols are hidden?

Do you have classes with the same names in each of the shared libraries?

Can you link it all together as one static application and prove it works like that?
# 3  
Old 07-16-2008
using the following flags while loading the library will solve the above problem
BIND_DEFERRED | DYNAMIC_PATH | BIND_RESTRICTED | BIND_FIRST

you can get more details abt the flags from hpux site.. but nowhere it says that these flags will solve the above problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C/C++ shared libraries on Linux.

This is the first time that I created a dynamic library in linux and although the program works, I do not get the correct information about the library when executing ldd. I explain the details: 1) Source code: bye_fn.c: #include <stdio.h> #include "hello.h" void bye (const char*... (9 Replies)
Discussion started by: jose_spain
9 Replies

2. Solaris

Self contained shared libraries

Does anyone know whether it is possible to make self contained shared libraries ? (.so files). If so, what is the way to do it ? ---------- Post updated at 08:03 AM ---------- Previous update was at 07:56 AM ---------- On Solaris that is. (6 Replies)
Discussion started by: lkb
6 Replies

3. Red Hat

shared libraries problem

hi, while running the below query it gives the shared libraries prmblem, $ cd /oracle/app/product/fmw/asinst_1/bin/ $ ./opmnctl status /oracle/app/product/fmw/Oracle_IDM1/opmn/bin/opmn: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: Permission... (0 Replies)
Discussion started by: rahulsword
0 Replies

4. AIX

Loaded Shared Libraries

Hi, I have a problem about loaded shared libraries. I'm issuing ‘procldd' for a process and AIX shows me the loaded shared libraries. I'm collecting these libraries and counting their size. They were 350MB. After this, I'm issuing ‘ps vx' and I'm seeing that the process takes 130MB from AIX's... (1 Reply)
Discussion started by: jhatzics
1 Replies

5. UNIX for Advanced & Expert Users

Shared Libraries- CRITICAL !!

Hi, I am trying to create a shared library from a .c file using gcc -c -fpic -I/usr/local/include Chksum.C -o Chksum.o gcc -shared -o libtclcksum.so Chksum.o when i try to load this shared library libtclcksum.so in tclsh % load libtclcksum.so I get the following error: couldn't load... (1 Reply)
Discussion started by: archana485
1 Replies

6. UNIX for Advanced & Expert Users

static and shared libraries

can someone explain whether my understanding is correct lets suppose we have a program that uses library x. if x is static then the code of x will be part of our program, so if we're going to have 5 executables of our program, then each executable will have x as part of it. Also, x does not... (2 Replies)
Discussion started by: JamesByars
2 Replies

7. Linux

Shared Libraries

How do i make a library shared say i have a library a.so which i have just compiled. I want to make it shared how do i make it Next Queation is what is the difference between a.so.0 a.so.1 a.so.2 & a.so :rolleyes: (1 Reply)
Discussion started by: wojtyla
1 Replies

8. UNIX for Dummies Questions & Answers

Clarification about shared Libraries

I have a doubt about the shared libraries. Where do you set the path for the shared libaries, for the dynamic loader to locate. Any suggestion would be of great help. thanks (3 Replies)
Discussion started by: ramkumar_gr
3 Replies

9. Programming

shared libraries

I am compiling code which produces .a and .la libraries. How can I produce .so libraries? I know that gcc -shared does but how? (2 Replies)
Discussion started by: thalex
2 Replies

10. Programming

Shared libraries

Hello everybody, I am having major problems at the moment with shared libraries and I have to little knowledge of them to solve them. So please, please help me :) Ok this is the problem: I have a library A, which uses B and C, and C uses again D. If I try to run A as plugin in apache,... (0 Replies)
Discussion started by: Micky
0 Replies
Login or Register to Ask a Question