Problem loading a shared library with dlopen

Problem loading a shared library with dlopen

Post by norton_.. » Fri, 15 Oct 1999 04:00:00



Hello.

I am trying to build a very simple NSAPI plugin for a Netscape
Enterprise server running on SunOS. To do this, I have built a
little C++ test program that, unfortunatley refuses to load.
What I am doing is a little bit Netscape specific, but I think
that the problem I am experiencing is something more related
to UNIX shared libraries, and ldopen, than to Netscape as such.
So please disregard the fact that Netscape is involved and tell
me if I'm doing something very wrong when I am creating my .so
file.

This is the error message that the server gives me when
I try to start the server (use the shared library):

conf_init: Error running init function(late) load-modules: dlopen of
/opt/netscape/suitespot/https-jaco/example.so failed (ld.so.1: ns-httpd:
fatal: relocation error: file
/opt/netscape/suitespot/https-jaco/example.so: symbol
__1cDstdZ__RTTI__1nDstdJbad_alloc__: referenced symbol not found)
server exit: status 1

The code is compiled like this:

CC -G -DNET_SSL -DSOLARIS -D_REENTRANT -DMCC_HTTPD -DXP_UNIX -DSPAPI20
-KPIC -mt -I/opt/netscape/suitespot/include
-I/opt/netscape/suitespot/include/base
-I/opt/netscape/suitespot/include/frame example.cpp -h example.so -o
example.so

And the source looks like this:

#include "nsapi.h" //Netscape stuff
#include <map>
#include <string>
using namespace std;

// The problem goes away if I do not use a map. However I
// must do so... :-(

extern "C" NSAPI_PUBLIC int hello_client(pblock *param, Session *sn,
Request *rq)
{
  map<string, string, less<string> > myMap;
  myMap["test"] = "Hello world";
  return REQ_PROCEED;

Quote:}

Environment:
Compiler:         CC: WorkShop Compilers 5.0 98/12/15 C++ 5.0
Platform:         SunOS v5.6
Netscape server:  Netscape-Enterprise v3.5.1

I have tried to set the LD_LIBRARY_PATH but it did not help.
The shared library loads if I do not use STL or any other
libraries. Any tips or ideas about what I am doing wrong would
be greatly appreciated.

Thank you,


Software developer / Netch Technologies AB / Lund / Sweden.

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Problem loading a shared library with dlopen

Post by Moritz Barsnic » Wed, 20 Oct 1999 04:00:00


Hi there,



> conf_init: Error running init function(late) load-modules: dlopen of
> /opt/netscape/suitespot/https-jaco/example.so failed (ld.so.1: ns-httpd:
> fatal: relocation error: file
> /opt/netscape/suitespot/https-jaco/example.so: symbol
> __1cDstdZ__RTTI__1nDstdJbad_alloc__: referenced symbol not found)
> server exit: status 1
> The code is compiled like this:
> CC -G -DNET_SSL -DSOLARIS -D_REENTRANT -DMCC_HTTPD -DXP_UNIX -DSPAPI20
> -KPIC -mt -I/opt/netscape/suitespot/include
> -I/opt/netscape/suitespot/include/base
> -I/opt/netscape/suitespot/include/frame example.cpp -h example.so -o
> example.so

Since nobody seems to have answered (at least at my end of the newsfeed),
I'll give it shot:

Have you tried linking the module statically against libstdc++? Do you have
another object file, which you may have to link to this object?

Just guessing,
Moritz.  :)

--
All opinions expressed above are my own and not approved by my employer.

 
 
 

Problem loading a shared library with dlopen

Post by Boris Goldber » Wed, 20 Oct 1999 04:00:00


Looks like you need to compile your code with -rtti option


> Hi there,



> > conf_init: Error running init function(late) load-modules: dlopen of
> > /opt/netscape/suitespot/https-jaco/example.so failed (ld.so.1: ns-httpd:
> > fatal: relocation error: file
> > /opt/netscape/suitespot/https-jaco/example.so: symbol
> > __1cDstdZ__RTTI__1nDstdJbad_alloc__: referenced symbol not found)
> > server exit: status 1

> > The code is compiled like this:

> > CC -G -DNET_SSL -DSOLARIS -D_REENTRANT -DMCC_HTTPD -DXP_UNIX -DSPAPI20
> > -KPIC -mt -I/opt/netscape/suitespot/include
> > -I/opt/netscape/suitespot/include/base
> > -I/opt/netscape/suitespot/include/frame example.cpp -h example.so -o
> > example.so

 
 
 

1. Shared variable between main() and loaded shared library - dlopen()

I created an executable that loads a shared library via dlopen().
The main program and the shared library use an identical object file
at link time. I expect the address of a particular variable to be
different at runtime, but I notice that the variable is actually identical
by address.
What needs to be done in order for the variable to have
2 separate addresses. Is it a link issue ? Is it an different option
in dlopen() ? I am using the standard C++ compiler (xlC_r) and
makeC++SharedLib_r.
This behavior appears also under HP-UX, Linux and Solaris.
Thanks for your help.

2. >>> F R E E V A C A T I O N S <<<

3. Problem loading a shared library with dlopen

4. Article

5. Shared library loading shared library.

6. Tekram DC390 SCSI host adapter problems

7. Shared Library Problem::: dlopen()

8. Micron computer for linux??

9. Problem with dlopen and custom shared library.

10. error in loading shared libraries: libXmu.so.6: cannot open shared object

11. Loading libraries run-time: dlopen, dlsym, dlclose

12. Solaris 10 issue? Failed dlopen() leaves library loaded.

13. loading dynamic libraries with dlopen