Operating System - Linux
1753773 Members
5866 Online
108799 Solutions
New Discussion юеВ

Re: LD_PRELOAD and libcl.sl

 
sachin myneni
Advisor

LD_PRELOAD and libcl.sl

Hello,

I am having trouble with running my application HP-UX B.11.11.

I have an executable (a.exe) that dynamically loads a shared library (b.so). I get an undefined symbol:
/usr/lib/pa20_64/dld.sl: Unsatisfied code symbol 'FTN_DTOI' in load module '/homes/dudee/myneni/workarea/exec/b.so'

I tried setting the following environment variable at runtime:
"LD_PRELOAD=/usr/lib/pa20_64/libcl.sl"
but that doesn't help. Same message as above.

If I list "-L/usr/lib/pa20_64/ -lcl" in the link line, I get:
"Error: Cannot dlopen load module '/homes/dudee/myneni/workarea/exec//b.so' because it contains thread specific data."

At this point, I had -Wl,-aarchive, which I changed to -Wl,-ashared_archive and I get the following:
Cannot dlopen load module '/usr/lib/pa20_64/libcl.2' because it contains thread specific data.
With or without LD_PRELOAD pointing to /usr/lib/pa20_64/libcl.sl.

Can someone help me understand how to fix this issue?

Thanks in advance
-Sachin
27 REPLIES 27
Carlos Roberto Schimidt
Regular Advisor

Re: LD_PRELOAD and libcl.sl

Hi,

Try put path from your shared library in SHLIB_PATH enviroment variable.

Schimidt
Sandman!
Honored Contributor

Re: LD_PRELOAD and libcl.sl

Hi Sachin,

Could you provide more information about your server's architecture etc...
# uname -a
# file a.exe

thx
sachin myneni
Advisor

Re: LD_PRELOAD and libcl.sl

Here is the runtime environment and the output of file on both the executable and the shared object:

myneni@hp76 BOM_opti/os-mbd-fem > uname -a
HP-UX hp76 B.11.11 U 9000/785 3968680693 unlimited-user license
myneni@hp76 BOM_opti/os-mbd-fem > file ~/os_binaries/os80d_HP-UX_42_64mp
/homes/dudee/t/tad/os_binaries/os80d_HP-UX_42_64mp: ELF-64 executable object file - PA-RISC 2.0 (LP64)
myneni@hp76 BOM_opti/os-mbd-fem > file ~/workarea/p4_mbd/mbd/exec/HP-UX_64mp/nusolver.so
/homes/dudee/myneni/workarea/p4_mbd/mbd/exec/HP-UX_64mp/nusolver.so: ELF-64 shared object file - PA-RISC 2.0 (LP64)

myneni@hp76 BOM_opti/os-mbd-fem > chatr ~/workarea/p4_mbd/mbd/exec/HP-UX_64mp/nusolver.so
/homes/dudee/myneni/workarea/p4_mbd/mbd/exec/HP-UX_64mp/nusolver.so:
64-bit ELF shared library
shared library dynamic path search:
LD_LIBRARY_PATH enabled first
SHLIB_PATH enabled second
embedded path enabled third /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/nu_libs:/a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX:/opt/fortran90/lib/pa20_64:/usr/lib/pa20_64:/opt/aCC/lib/pa20_64:/usr/lib/pa20_64:/usr/lib/pa20_64:/opt/langtools/lib/pa20_64
shared vtable support disabled
segments:
index type address flags size
5 text 4000000000000000 z---c D (default)
6 data 8000000100000000 ---m- D (default)
kernel assisted branch prediction enabled
lazy swap allocation for dynamic segments disabled
myneni@hp76 BOM_opti/os-mbd-fem >

Here is the information on the build machine:

myneni@hp77 p4_mbd/mbd > uname -a
HP-UX hp77 B.11.11 U 9000/785 2005242756 unlimited-user license
myneni@hp77 p4_mbd/mbd >


Thanks
-Sachin


Sandman!
Honored Contributor

Re: LD_PRELOAD and libcl.sl

Hi Sachin,

How about the output of the following commands...

# file a.exe
# ldd -v a.exe
# file /homes/dudee/myneni/workarea/exec/b.so
# ldd -v /homes/dudee/myneni/workarea/exec/b.so
Sandman!
Honored Contributor

Re: LD_PRELOAD and libcl.sl

Hi Sachin,

How about the output of the following commands...

# file a.exe
# ldd -v a.exe
# file /homes/dudee/myneni/workarea/exec/b.so
# ldd -v /homes/dudee/myneni/workarea/exec/b.so

...also post the command used for compilation.
sachin myneni
Advisor

Re: LD_PRELOAD and libcl.sl

Hi Sandman,

I don't have ldd on any of my HP-UX systems, so I cannot give the output of 2 of the commands. But here is the output of 'file' from both the executable and shared object:
Executable:
myneni@hp76 BOM_opti/os-mbd-fem > file ~tad/os_binaries/os80d_HP-UX_42_64mp
/homes/dudee/t/tad/os_binaries/os80d_HP-UX_42_64mp: ELF-64 executable object file - PA-RISC 2.0 (LP64)
Shared Object:
myneni@hp76 BOM_opti/os-mbd-fem > file /homes/dudee/myneni/workarea/p4_mbd/mbd/exec/HP-UX_64mp/nusolver.so
/homes/dudee/myneni/workarea/p4_mbd/mbd/exec/HP-UX_64mp/nusolver.so: ELF-64 shared object file - PA-RISC 2.0 (LP64)

COMPILATION FLAGS:
FORTRAN compilation flags: /opt/fortran90/bin/f90 +U77 +DA2.0W +DS2.0 -Df90 +O2 +Z +Onoopenmp +source=default +noextend_source
C++ Compilation flags: /opt/aCC/bin/aCC +DA2.0W +DS2.0 -Dhpf90 -Dhpux +O2 +Z
Verbose Link output:

/opt/aCC/bin/aCC +DA2.0W +DS2.0 -Wl,-aarchive,+vnocompatwarnings -v //OBJ_LIST// +O2 -b -L/a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/nu_libs -L/a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX -lnumerflib_HP-UX_64mp -lnumerclib_HP-UX_64mp -lblas_HP-UX_64mp -lblas_HP-UX_64mp -L/opt/fortran90/lib/pa20_64 -lU77 -lF90_parallel -L/usr/lib/pa20_64 -lstd -lstream -lCsup -lm -L/opt/aCC/lib/pa20_64 -ldemangle -lcl /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX/cflex_64.o /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX/lm_new_cflex_64.o -llmgr_cflex_64 -lcrvs_cflex_64 -lsb_cflex_64 -L/usr/lib/pa20_64 -o nusolver.so
LPATH=/usr/lib/pa20_64:/opt/langtools/lib/pa20_64
/usr/ccs/bin/ld -b -o /tmp/nusolver.so_myneni +I__shlTerm -aarchive +vnocompatwarnings acceleration.o ...... zipother.o -L /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/nu_libs -L /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX -lnumerflib_HP-UX_64mp -lnumerclib_HP-UX_64mp -lblas_HP-UX_64mp -lblas_HP-UX_64mp -L /opt/fortran90/lib/pa20_64 -lU77 -lF90_parallel -L /usr/lib/pa20_64 -lstd -lstream -lCsup -lm -L /opt/aCC/lib/pa20_64 -ldemangle -lcl /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX/cflex_64.o /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX/lm_new_cflex_64.o -llmgr_cflex_64 -lcrvs_cflex_64 -lsb_cflex_64 -L /usr/lib/pa20_64 >/var/tmp/AAAa17623 2>&1 removing /var/tmp/AAAa17623 nusolver.so done




The following are the compilation flags for the executable (optistruct.exe) that loads the shared object built above:
FORTRAN: /opt/fortran90/bin/f90 +U77 +DA2.0W +DS2.0 -Df90 +O3 +Onoopenmp +source=default +noextend_source
C : cc +DA2.0W +DS2.0 -Dhpf90 -Dhpux +O3
C++ : /opt/aCC/bin/aCC +DA2.0W +DS2.0 -Dhpf90 -Dhpux +O3
LD: : /opt/aCC/bin/aCC +DA2.0W +DS2.0 -Wl,-aarchive,+vnocompatwarnings +O3 -s +Oparallel


Thank you
-Sachin


sachin myneni
Advisor

Re: LD_PRELOAD and libcl.sl

That was quite unreadable. Sorry. Here goes again:

Hi Sandman,

I don't have ldd on any of my HP-UX systems, so I cannot give the output of 2 of the commands. But here is the output of 'file' from both the executable and shared object:

Executable:
-----------
myneni@hp76 BOM_opti/os-mbd-fem > file ~tad/os_binaries/os80d_HP-UX_42_64mp
/homes/dudee/t/tad/os_binaries/os80d_HP-UX_42_64mp: ELF-64 executable object file - PA-RISC 2.0 (LP64)

Shared Object:
--------------
myneni@hp76 BOM_opti/os-mbd-fem > file /homes/dudee/myneni/workarea/p4_mbd/mbd/exec/HP-UX_64mp/nusolver.so
/homes/dudee/myneni/workarea/p4_mbd/mbd/exec/HP-UX_64mp/nusolver.so: ELF-64 shared object file - PA-RISC 2.0 (LP64)


COMPILATION FLAGS:
==================
FORTRAN compilation flags:
--------------------------
/opt/fortran90/bin/f90 +U77 +DA2.0W +DS2.0 -Df90 +O2 +Z +Onoopenmp +source=default +noextend_source

C++ Compilation flags:
----------------------
/opt/aCC/bin/aCC +DA2.0W +DS2.0 -Dhpf90 -Dhpux +O2 +Z


Verbose Link output:
--------------------
/opt/aCC/bin/aCC +DA2.0W +DS2.0 -Wl,-aarchive,+vnocompatwarnings -v //OBJ_LIST// +O2 -b -L/a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/nu_libs -L/a/homes/dudee/m
/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX -lnumerflib_HP-UX_64mp -lnumerclib_HP-UX_64mp -lblas_HP-UX_64mp -lblas_HP-UX_64mp -L/opt/fortran90/lib/pa20_64 -lU77 -lF90_parallel -L/usr/lib/pa20_64 -lstd -lstream -lCsup -lm -L/opt/aCC/lib/pa20_64 -ldemangle -lcl /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX/cflex_64.o
/a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX/lm_new_cflex
_64.o -llmgr_cflex_64 -lcrvs_cflex_64 -lsb_cflex_64 -L/usr/lib/pa20_64 -o nusolver.so
LPATH=/usr/lib/pa20_64:/opt/langtools/lib/pa20_64
/usr/ccs/bin/ld -b -o /tmp/nusolver.so_myneni +I__shlTerm -aarchive +vnocompatwarnings acceleration.o ...... zipother.o -L /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/nu_libs -L /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX -lnumerflib_
HP-UX_64mp -lnumerclib_HP-UX_64mp -lblas_HP-UX_64mp -lblas_HP-UX_64mp -L /opt/fortran90/lib/pa20_64 -lU77 -lF90_parallel -L /usr/lib/pa20_64 -lstd -lstream -lCsup -lm -L /opt/aCC/lib/pa20_64 -ldemangle -lcl /a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX/cflex_64.o
/a/homes/dudee/m/myneni/workarea/p4_mbd/mbd/OSLIBS/LIB-HP-UX/lm_new_cflex
_64.o -llmgr_cflex_64 -lcrvs_cflex_64 -lsb_cflex_64 -L /usr/lib/pa20_64 >/var/tmp/AAAa17623 2>&1 removing /var/tmp/AAAa17623 nusolver.so done





The following are the compilation flags for the executable (optistruct.exe) that loads the shared object built above:

FORTRAN: /opt/fortran90/bin/f90 +U77 +DA2.0W +DS2.0 -Df90 +O3 +Onoopenmp +source=default +noextend_source

C : cc +DA2.0W +DS2.0 -Dhpf90 -Dhpux +O3

C++ : /opt/aCC/bin/aCC +DA2.0W +DS2.0 -Dhpf90 -Dhpux +O3

LD: : /opt/aCC/bin/aCC +DA2.0W +DS2.0 -Wl,-aarchive,+vnocompatwarnings +O3 -s +Oparallel


Thank you
-Sachin
Sandman!
Honored Contributor

Re: LD_PRELOAD and libcl.sl

Hi Sachin,

Thanks for the legible output. From your last post it looks like you have the wrong library path for linking the "libcl.2" library (that's if I'm reading the aCC compilation correctly).

Under your "Verbose Link output" section the lib path is specified...

"-L/opt/aCC/lib/pa20_64 -ldemangle -lcl"

...which is incorrect since the libcl.sl is found under "/usr/lib/pa20_64". In fact you can search for it as:

# find / -name "libcl.sl" -type f
<...should show up only in /usr/lib/pa20_64>

Another suggestion would be not to use "-Wl,-aarchive" and let the defaults apply. The default action is to link the shared lib (and if it's not found bind the executable with the archive version). See ld(1) for details.

cheers!
Dennis Handly
Acclaimed Contributor

Re: LD_PRELOAD and libcl.sl

You first need to explain what language(s) are in a.exe and what language(s) are in b.so.

It seems that a.exe is C++ and b.so is Fortran?
If you are doing that, you should link a.exe with libcl.sl.

A similar issue occurs with C and aC++ and we have a nice web explaining what to do:
http://docs.hp.com/en/7133/distributing.htm

I would have expected your first LD_PRELOAD to work, though I would have used .../libcl.2.

Your second attempt, -lcl will not work unless you have the LD_PRELOAD too.

You said you had -Wl,-aarchive, where?
As Sandman suggests, you should using the default, especially when creating shlibs.
From your link line of a.exe, that's your problem! If you insist upon using archives, you must have the system libs as shared.
You can use -l:libm.a for performance.

Note you seem to be including all of the aC++ libs? Why don't they appear twice in the aCC -v output? (Ah, aCC -b.)
In particular, you should have -ldemangle
before the default libs. And there should be no user libs/objects after them.
cflex_64.o...-lsb_cflex_64

>I don't have ldd on any of my HP-UX systems

You should have /usr/ccs/bin/ldd on your system. If not, you need a newer linker patch. (And we really need that ldd or chatr output.)

Also for aCC, you should change +DA2.0W to +DD64.

A comment about Sandman's comment:
-L/opt/aCC/lib/pa20_64 -ldemangle -lcl"
...which is incorrect

This isn't incorrect since -L paths are additive and -lcl will be found under the default or previous -L paths.