Operating System - HP-UX
1753805 Members
7533 Online
108805 Solutions
New Discussion юеВ

Re: Creating shared library

 
Voloshin Igor
Occasional Contributor

Creating shared library

Hi,
I'm trying to create a shared library that uses another
third party static (.a) library. During compilation I got the message:

ld: Invalid loader fixup for symbol "$000001B5".

Probably, the library sources were compiled without +z option, but I haven't these sources.
There is no problem with creating an executable that uses this library.
May by somebody can help me with that.
Thanks,
Igor
3 REPLIES 3
kalimuthu
New Member

Re: Creating shared library

Hello Voloshin,

Here i have tested with sample code.

# cat sdisplay.c
#include
void sdisplay()
{
printf("Message from static lib\n");
}


# cat ddisplay.c
#include
void ddisplay()
{
sdisplay();
printf("Message from dynamic lib\n");
}

# cat main.c
#include
int main()
{
ddisplay();
printf("Message from main");
return 0;
}

# cc -c sdisplay.c
# ar cq libsdisplay.a sdisplay.o
# cc +z -c ddisplay.c
# ld -b -o libddisplay.so ddisplay.o\
-L. -lsdisplay
# cc main.c -L. -lddisplay
# ./a.out

Message from static lib
Message from dynamic lib
Message from main

First created dynamic object with +z option, use ld to create the dynamic library with static.

I hope this will work for your problem.

regards,
kalimuthu

Manish Srivastava
Trusted Contributor

Re: Creating shared library

Hi Igor,

Can you sheare the compile line options for the .o as well as the library.

manish
ranganath ramachandra
Esteemed Contributor

Re: Creating shared library

building a shared library needs that the object contain position-independent code (pic) - this is what is achieved with +z compile option.

if the object code is non-pic, there is no way to build a shared library from it.

also i think there is no supported way of converting non-pic code to pic.
 
--
ranga
[i work for hpe]

Accept or Kudo