Matthias Pfisterer wrote:
> Hi,
> 
> a funktion void _init(void) is called on loading a shared library, if it
> exists. See dlopen(3).

This didn't help, i have reduced it to this example:


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



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?

thanks again for any help,

Marcel

PS: I will send this question to the gcc mailing list as well
     probably they know.
> 
> Matthias
> 
> 
> Marcel Ruff wrote:
> 
>>Hi,
>>
>>i am using Linux 2.4.4-4 with JDK 1.3.1
>>
>>I want to call one method in a native, shared C++ library from
>>Java, using JNI.
>>
>>The C++ .so lib depends on other .so libs
>>which have many C++ classes which are
>>usually initialized automatically on startup before the
>>main() method (if i invoke
>>the old C++ application executable).
>>
>>Now it seems, that the java System.load()
>>does not call something like _main_()
>>
>>I believe all my global C++ classes are
>>uninitialized - as i get this error:
>>
>>--------------------------
>>   An unexpected exception has been detected in native code outside the VM.
>>   Unexpected Signal : 11 occurred at PC=0x405927d9
>>   Function
>>name=__as__t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0RCt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0
>>Library=/usr/lib/libstdc++-libc6.1-1.so.2
>>---------------------------
>>
>>Is there any lowlevel main() in the Linux clib
>>which i can invoke manually?
>>
>>thanks for any hint,
>>
>>Marcel
>>
>>--
>>Marcel Ruff
>>mailto:[EMAIL PROTECTED]
>>http://www.lake.de/home/lake/swand/
>>http://www.xmlBlaster.org
>>
>>----------------------------------------------------------------------
>>To UNSUBSCRIBE, email to [EMAIL PROTECTED]
>>with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
>>
> 



-- 
Marcel Ruff
mailto:[EMAIL PROTECTED]
http://www.lake.de/home/lake/swand/
http://www.xmlBlaster.org


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to