BladeSystem Forums have moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

pa-risc & dlopen for 32-bit

Occasional Contributor

pa-risc & dlopen for 32-bit

I'm trying to open a shared lib on a pa-risc system like this:

dlhdl = dlopen("libmydll.sl",RTLD_LAZY|RTLD_GLOBAL);
printf("%s\n",dlerror());

When the DLL & app are compiled as 32-bit this always fails - with an error saying that the it cannot open the shared lib libmydll.sl ...

However it works when I compile both the DLL & app as 64-bit (+DD64).

Is there any additional settings to get dlopen to work in 32-bit mode

(all the env settings are the same when I try the tests i.e. SHLIB_PATH, LD_LIBRARY_PATH etc are all the same)
3 REPLIES
Acclaimed Contributor

Re: pa-risc & dlopen for 32-bit

If you expect to use SHLIB_PATH with the SOM dld.sl, you must link with -Wl,+s. Or use "chatr +s enable executable".
Occasional Contributor

Re: pa-risc & dlopen for 32-bit

the chatr seems to work. Now its a different issue. My shared library is built with "-mt" (linked with pthreads).

So when I do a dlopen/shl_load of this library I get:
/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local Storage: /usr/lib/libpthread.1

The documentation seems to suggest that I can compile my shared library with the +tls=dynamic option and I should'nt see this anymore ... however that does not seem to work. I still get the same error messsage.

By the way the versions I have is:
aCC: HP ANSI C++ B3910B A.03.60
HPUX B.11.11 U 9000/800


(exporting LD_PRELOAD does solve the problem - but I'd like to be able to resolve it without having users do this)

Thanks
Highlighted
Acclaimed Contributor

Re: pa-risc & dlopen for 32-bit

>"-mt" (linked with pthreads).

You shouldn't link shlibs with libpthread. -mt has been fixed to no longer do that with -b. Only the executable should be linked with libpthread.

>I can compile my shared library with the +tls=dynamic option and I shouldn't see this anymore

That only works for your shlib, not for libpthread. And +tls=dynamic doesn't work for PA.

>exporting LD_PRELOAD does solve the problem

As I mentioned, if you are actually creating threads, then link your executables with libpthread.

If you aren't creating threads, then don't link your shlibs with -mt.