- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: shared libraries - different behaviour in hp-u...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2010 06:21 AM
тАО04-05-2010 06:21 AM
shared libraries - different behaviour in hp-ux and linux
A shared library a.sl contains a module a.c with 2 functions a and b.
Function b is calling some other function c, not contained in the library.
My main program is only calling a, does not need b (and so not c).
On HP-UX 11.11 PA-RISC this is working.
On Linux i get an unresolved symbol c when im am linking main.
Commands on HP-UX:
cc +z -c main.c
cc +z -c a.c
ld -b -o a.sl a.o
cc +z main.o a.sl -o main
./main
hello world
Commands on Linux:
cc -c -o main.o main.c
cc -c -o a.o a.c
ld -shared -o a.so a.o
cc main.o a.so -o main
a.so: undefined reference to `c'
same result on Linux with liba.so:
ld -shared -o liba.so a.o
cc -L. -la main.o -o main
./liba.so: undefined reference to `c'
Im am porting a programs from HP-UX to Linux. Is there a solution for this kind of problem?
I hope im am using the right forum, because this conciders both HP-UX and Linux.
Joachim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2010 10:50 AM
тАО04-05-2010 10:50 AM
Re: shared libraries - different behaviour in hp-ux and linux
If you used the ELF linker you would get a shlib unsat warning.
>Is there a solution for this kind of problem?
Define "c" or provide the shlib that has the definition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2010 12:22 PM
тАО04-05-2010 12:22 PM
Re: shared libraries - different behaviour in hp-ux and linux
You are right, i am not porting to integrity.
So the only HP-UX part of the question is:
Why do i *not* get an error on HP-UX with this example.
> Define "c" or provide the shlib that has the definition.
This will work in my example. But in real life in the sw i am porting, providing the shlibs leads to other undefined symbols and multiple definitions.
Greetings,
Joachim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2010 05:34 PM
тАО04-05-2010 05:34 PM
Re: shared libraries - different behaviour in hp-ux and linux
cc -Wl,--allow-shlib-undefined main.o a.so -o main
on linux.
The 32-bit HP-UX linker defaults to allowing shared libraries to have undefined symbols when linking a program. (The 64-bit HP-UX linker defaults to an error just as linux does and requires +allowunsats.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2010 07:54 PM
тАО04-05-2010 07:54 PM
Re: shared libraries - different behaviour in hp-ux and linux
Because you do, on Integrity. But it's a warning. (Standard is better than better. :-)
>Mike: The 64-bit HP-UX linker defaults to an error just as linux does and requires +allowunsats.
No, if the unsats are in a shlib, it's a warning.
ld: (Warning) Unsatisfied symbol "c" in file liba.so
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2010 09:13 PM
тАО04-05-2010 09:13 PM
Re: shared libraries - different behaviour in hp-ux and linux
You can resort to "lazy" linking. From what I can see this is the default on HP-UX.
Regards,
Goran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2010 05:51 AM
тАО04-06-2010 05:51 AM
Re: shared libraries - different behaviour in hp-ux and linux
Default on my HP-UX 11.11 64 Bit PA-RISC seems to be lazy linking without warning.
Solution for Linux is:
- Compile with -fpic or -fPIC
- Link with
--allow-shlib-undefined (no warning at link time)
or
--warn-unresolved-symbols
Joachim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2010 04:49 PM
тАО04-09-2010 04:49 PM