From: Marcel Ruff <ruff@swand.lake.de>
To: gcc <gcc@gcc.gnu.org>
Subject: Static initializer in shared libraries on Linux
Date: Sun, 16 Sep 2001 06:08:00 -0000 [thread overview]
Message-ID: <3BA4A44C.7080003@swand.lake.de> (raw)
Hi,
i have two .so libs, and get a sig 11 when
accessing a static string variable,
accessing a static variable of type char*
works fine:
InitTest.H
-----------
class InitTest
{
public: static char * charName;
public: static string stringName;
};
#if EXTERN_MAIN
char * InitTest::charName = "Hello charP";
string InitTest::stringName = string("Hello string");
# endif
-----------
compile this into libInitTest.so
xy.C
------------
#define EXTERN_MAIN 1
....
// Runs fine:
cout << "C++: the charName=" << InitTest::charName << endl;
// Sig 11 - core dump:
cout << "C++: the stringName=" << InitTest::stringName << endl;
...
------------
compile this into xy.so
xy.C is run by a Java JVM using JNI.
Looking into the .so libs:
---------------------
nm -o *.so | grep charName
libxy.so:00028910 D _8InitTest.charName
libxy.so:0001bf60 t _GLOBAL_.D._8InitTest.charName
libxy.so:0001bf30 t _GLOBAL_.I._8InitTest.charName
nm -o *.so | grep stringName
libxy.so:0002d4c8 B _8InitTest.stringName
--------------------
The "string" class is never initialized whereas
the char* acts as expected!
Why?
Why is there no entry in libInitTest.so?
What do i have to change to get this running?
thanks for any help,
Marcel
--
Marcel Ruff
mailto:ruff@swand.lake.de
http://www.lake.de/home/lake/swand/
http://www.xmlBlaster.org
reply other threads:[~2001-09-16 6:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3BA4A44C.7080003@swand.lake.de \
--to=ruff@swand.lake.de \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).