🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3389

Re: C++ globals and shared lib, how to ?

#3389
From: Frank Pilhofer
Date: Mon, 01 Feb 1999 00:00
31 lines
1606 bytes
In article <36B5EA0E.2361@imag.fr>, Yves Dufournaud wrote:
>
> I'am loading a file dynamic.o using dlopen
> this file is c++ with global object inside.
> but when I load it with a dlopen and using RTLD_NOW
> constructor of global object are not called.
>

 They should be. Global constructors are called from special
initialization hooks in an ELF shared library.

>
> I've compiled it using 
> g++ -shared dynamic.cc -export-dynamic
>

 Please try

  g++ -fPIC -c dynamic.cc
  g++ -fPIC -o dynamic.so dynamic.o

 This works for me. You also should upgrade your compiler. Gcc 2.7.2
has some serious drawbacks when building shared libraries. Try gcc
2.8.x or egcs 1.1.x.

	Frank

-- 
 + Frank Pilhofer                        fp@informatik.uni-frankfurt.de  +
 |                                      http://www.uni-frankfurt.de/~fp/ |
 +---- Life would be a very great deal less weird without you.  - DA ----+
Technical Details
Message-ID: <slrn7bc27l.k9.fp@rose.fpx.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36B5EA0E.2361@imag.fr>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc89c,3b56ba1236b2e4f
X-Google-Attributes: gidfc89c,public
X-Google-Thread: 10ba33,3b56ba1236b2e4f
X-Google-Attributes: gid10ba33,public
X-Google-Thread: 11035d,3b56ba1236b2e4f
X-Google-Attributes: gid11035d,public
From: fp@informatik.uni-frankfurt.de (Frank Pilhofer)
Subject: Re: C++ globals and shared lib, how to ?
Date: 1999/02/01
Message-ID: <slrn7bc27l.k9.fp@rose.fpx.de>
X-Deja-AN: 439692630
References: <36B5EA0E.2361@imag.fr>
Organization: Frankfurt University Computing Center
Reply-To: fp@informatik.uni-frankfurt.de
Newsgroups: comp.unix.programmer,comp.unix.solaris,gnu.g++.help