Unix Technical Forum

Order loading shared libraries.

This is a discussion on Order loading shared libraries. within the HP-UX Operating System forums, part of the Unix Operating Systems category; --> Hello ! On AIX I may specify order loading shared libraries and therefore I may define order initializing non-local ...


Go Back   Unix Technical Forum > Unix Operating Systems > HP-UX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-16-2008, 06:22 PM
Michael Zavyalov
 
Posts: n/a
Default Order loading shared libraries.

Hello !

On AIX I may specify order loading shared libraries and therefore I may
define order initializing non-local static variables in different libraries.
How I may to do it on HP-UX ?

Michael.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-16-2008, 06:22 PM
jignaasu
 
Posts: n/a
Default Re: Order loading shared libraries.

"Michael Zavyalov" <mzav@isd.dp.ua> wrote in message news:<bosvcd$j5$1@mfdebug.isd.dp.ua>...
> Hello !
>
> On AIX I may specify order loading shared libraries and therefore I may
> define order initializing non-local static variables in different libraries.
> How I may to do it on HP-UX ?


by the order of shared libraries specified on the link command ? seems
to work in a simple case.

>
> Michael.

-----------------
cat > 1.c << \!
#include <iostream.h>
class A {
public:
A () { cout << "A" << endl ; }
} ;
A a;
!
cat > 2.c << \!
#include <iostream.h>
class B {
public:
B () { cout << "B" << endl ; }
} ;
B b;
!
cat > 3.c << \!
#include <iostream.h>
int main () { cout << "main" << endl ; }
!
aCC +z -b 1.c -o 1.sl
aCC +z -b 2.c -o 2.sl
aCC 3.c 1.sl 2.sl
../a.out
aCC 3.c 2.sl 1.sl
../a.out
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-16-2008, 06:22 PM
Paul Pluzhnikov
 
Posts: n/a
Default Re: Order loading shared libraries.

"Michael Zavyalov" <mzav@isd.dp.ua> writes:

> On AIX I may specify order loading shared libraries and therefore I may
> define order initializing non-local static variables in different libraries.


The order of initialization of global C++ objects in separate
compilation units is *undefined*. If your program depends on such
order, you are fighting a loosing battle: whatever works today,
may break with the next compiler patch.

You'll be much better off redesigning your program to *not* depend
on the order of initialization of globals, or better yet not to
have any globals at all. Singleton pattern may help you get rid
of them.

Cheers,
--
In order to understand recursion you must first understand recursion.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-16-2008, 06:23 PM
jignaasu
 
Posts: n/a
Default Re: Order loading shared libraries.

Paul Pluzhnikov <ppluzhnikov@earthlink.net> wrote in message news:<u3ccskcrv.fsfYB8X@earthlink.net>...
> "Michael Zavyalov" <mzav@isd.dp.ua> writes:
>
> > On AIX I may specify order loading shared libraries and therefore I may
> > define order initializing non-local static variables in different libraries.

>
> The order of initialization of global C++ objects in separate
> compilation units is *undefined*. If your program depends on such
> order, you are fighting a loosing battle: whatever works today,
> may break with the next compiler patch.


oh yes, there is at least one such known problem, if you depend on any
order. between PA32 and any of PA64/IA32/IA64 the order definitely
changed.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:31 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com