Subject: Fwd: C++ woes.
To: None <port-arm32@NetBSD.ORG>
From: Paul Wain <pwain@nc.com>
List: port-arm32
Date: 11/24/1997 18:58:15
--=_NCMail_DsDk7B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit




[]

--
This mail was sent from a 233Mhz StrongARM N|C

--=_NCMail_DsDk7B
Content-Type: multipart/mixed; boundary="=_NCMail_DsDk7C"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment


--=_NCMail_DsDk7C
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Forward</TITLE>
<BASE HREF=3D"file:">
</HEAD>
<BODY>

<P><BR>
<BR>
</P>
</BODY>
</HTML>
<HTML>
<HEAD>
</HEAD>
<BODY>

<P><FONT COLOR=3D#0000cc>--</FONT><FONT COLOR=3DRED><BR>
This mail was sent from a 233Mhz StrongARM N|C</FONT></P>
</BODY>
</HTML>


--=_NCMail_DsDk7C
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit

Envelope-NCMailBegin: pwain:deimos.nc.com:POP3
Envelope-From: pwain@nc.com
Envelope-To: port-arm32-owner-PWAIN=nc.com@NetBSD.ORG
From: Paul Wain <pwain@nc.com>
Subject: Re: C++ woes.
Organization: Network Computer Inc.
Content-Type: multipart/alternative; boundary="=_NCMail_4kDk7A"
Content-Transfer-Encoding: 7bit
To: <port-arm32-owner-PWAIN=nc.com@NetBSD.ORG>
Message-Id: <Myce0Ancm@desktop-nc187.client.nc.com>
MIME-Version: 1.0
Date: Mon, 24 Nov 1997 18:50:52 GMT


--=_NCMail_4kDk7A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


Hi,

> I've been trying to compile the qt library, which uses C++, but I've come
> across a few problems. I've compiled both static and shared version. The
> static version seems to work (well, the simple tutorial examples work) but
> linking with the shared one results in core dumps.
>
> Have I done something wrong or is there a problem with -fPIC/pic and C++?

The main problem depends on whether you are using static class initializers in 
your library? If you are there is a small trick you need to use, otherwise you 
have found a bug (bearing in mind we are using dynamically linked C++ libraries 
here I doubt you have found a bug :)

Basically in the case of static initalizers your library also needs to link 
against /usr/lib/c++rt0.o

This is a small file that has some initalization code that when the library is 
'dlopen'ed gets called to initalize the shared library. (Basically it creates a 
.init stub which calls all __GLOBAL_.I._ functions (it also calls the 
destructor functions to). (The stub function it adds is called .init btw). [1]

Hope that helps.

Paul.

--
This mail was sent from a 233Mhz StrongARM N|C

--=_NCMail_4kDk7A
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Reply</TITLE>
<BASE HREF=3D"file:">
</HEAD>
<BODY>

<P>Hi,<PRE>&gt; I've been trying to compile the qt library, which uses=
 C++, but I've come
&gt; across a few problems. I've compiled both static and shared versi=
on. The
&gt; static version seems to work (well, the simple tutorial examples =
work) but
&gt; linking with the shared one results in core dumps.
&gt;
&gt; Have I done something wrong or is there a problem with -fPIC/pic =
and C++?</PRE>
The main problem depends on whether you are using static class initial=
izers in your library? If you are there is a small trick you need to u=
se, otherwise you have found a bug (bearing in mind we are using dynam=
ically linked C++ libraries here I doubt you have found a bug :)<BR>
<BR>
Basically in the case of static initalizers your library also needs to=
 link against /usr/lib/c++rt0.o<BR>
<BR>
This is a small file that has some initalization code that when the li=
brary is 'dlopen'ed gets called to initalize the shared library. (Basi=
cally it creates a .init stub which calls all __GLOBAL_.I._ functions =
(it also calls the destructor functions to). (The stub function it add=
s is called .init btw). [1]<BR>
<BR>
Hope that helps.<BR>
<BR>
Paul.<BR>
</P>
</BODY>
</HTML>
<HTML>
<HEAD>
</HEAD>
<BODY>

<P><FONT COLOR=3D#0000cc>--</FONT><FONT COLOR=3DRED><BR>
This mail was sent from a 233Mhz StrongARM N|C</FNT></P>
</BODY>
</HTML>


--=_NCMail_4kDk7A--

--=_NCMail_DsDk7C--

--=_NCMail_DsDk7B--