1841417 Members
3528 Online
110181 Solutions
New Discussion

Creating a shared object

 
SOLVED
Go to solution
devshlom
Regular Advisor

Re: Creating a shared object

Hi,

I added the "-fpic" to all the libs the my sl is being linked with and this solved the problem!!!
Now I have some running problems, but this is for a different thread.

tx all for the good answers.

shlom
Vineet K. Aggarwal
New Member

Re: Creating a shared object

I know this thread is closed, but I have a question for Dennis along the same lines I am hoping he can answer.

In response to the previous question:

"I will have to change the extension to "sl" - don't I?"

the response was:

"You don't "have" to but it is a good idea.
Otherwise ld won't find it with -ltest without extra work."

My application (for reasons I won't go into) depends on the shared library extensions to end in .so. As such, I don't want to change them to .sl. Can you please explain to me what "extra work" I need to do to make ld find my .so files? Right now, it can't find them unless I rename them to .sl.

Thank you so much!
Dennis Handly
Acclaimed Contributor

Re: Creating a shared object

>ME: On PA you use .sl. On IPF you use .sl.

Oops, I don't know if this confused anyone but this should say:
On PA you use .sl. On IPF you use .so.

>Vineet: I know this thread is closed, but I have a question

You should create your own thread so you can assign points and if useful include a URL to point to this thread.

>I don't want to change them to .sl. Can you please explain to me what "extra work" I need to do to make ld find my .so files?

You could do two things:
1) Create a symlink that points the .sl to the .so.
2) Change your link line to have: -l:libtest.so
Vineet K. Aggarwal
New Member

Re: Creating a shared object

Sorry about not creating a new thread -- I wanted you specifically to respond, so I wasn't sure if you would see my new thread otherwise. I will do that for sure next time.

As for your suggestion, I actually tried to use -l:, but it didn't work. I suspect this is because of the last sentence in the following excerpt from a doc on ld:

-l: library Search the library specified. Similar to the -l option except the current state of the -a option is not important. The library name must contain the prefix lib and end with a suffix of .a or .sl.

I got this from:
http://www.informatik.uni-frankfurt.de/doc/man/hpux/ld.1.html

I think it will only look for .a or .sl...
Dennis Handly
Acclaimed Contributor

Re: Creating a shared object

>Vineet: I actually tried to use -l:, but it didn't work.

I have no problems with: -L. -l:libfoo.so

>I suspect this is because of the last sentence in the following excerpt from a doc on ld:

Only the recommended/official suffixes are listed. But your issue could be due to the change in the linker. ld(1) now says:
The library name can be any valid filename. (Note that previous releases required that the library name contain the prefix lib and end with a suffix of .a or .sl.)