Re: linker questions.



Dennis Handly wrote:
Dave wrote:
I don't run HP-UX, but are looking to find out what flags would be used to build a shared library on HP-UX.
1) Do most people use the GNU linker, or HP's linker?

You can only use HP's linker.
You use -b to build a shlib.

2) Can someone post the output of 'man ld'

http://docs.hp.com/en/B2355-60130/ld_ia.1.html
http://docs.hp.com/en/B2355-60130/ld_pa.1.html

Thank you for those links. I'll take a look, but if you could make some suggestions I would appreciate it. Despite knowing Solaris pretty well, with access to the man pages, I could not work out what the the Sun equivalent were.

FWIW, I'm trying to help the developer of Automatically Tuned Linear Algebra Software (ATLAS) library build in better shared library support. It is currently broken on Solaris if the Sun linker is used, so I found what options the Sun linker needed. It would be good to add them for other operating systems too. So I'm trying to found out what they are for HP-UX and AIX. I think covering the GNU, Sun, HP and IBM linkers would cover 99% of users. At the moment, it only works for the GNU linker.

As a Solaris user, I'm fed up with too many GNUisms - I'm sure you HP-UX guys must be too!

Perhaps if they do get added, we could convince someone to try to build ATLAS on HP-UX and see if it builds.

3) Does anyone know the HP linkers equivalent of these GNU linker flags
-shared -soname
--whole-archive --no-whole-archive

You'll have to explain what they do. Do the last two extract ALL of an archive?

I think:
-shared == -b
-soname X == +h X
I won't try to explain what they do, as I don't fully understand it myself. But here is the text from the 'Options' section of the GNU linker manual.

http://sourceware.org/binutils/docs-2.19/ld/Options.html#Options

--whole-archive
For each archive mentioned on the command line after the --whole-archive option, include every object file in the archive in the link, rather than searching the archive for the required object files. This is normally used to turn an archive file into a shared library, forcing every object to be included in the resulting shared library. This option may be used more than once.

Two notes when using this option from gcc: First, gcc doesn't know about this option, so you have to use -Wl,-whole-archive. Second, don't forget to use -Wl,-no-whole-archive after your list of archives, because gcc will add its own list of archives to your link and you may not want this flag to affect those as well.




--no-whole-archive
Turn off the effect of the --whole-archive option for subsequent archive files.


--
I respectfully request that this message is not archived by companies as
unscrupulous as 'Experts Exchange' . In case you are unaware,
'Experts Exchange' take questions posted on the web and try to find
idiots stupid enough to pay for the answers, which were posted freely
by others. They are leeches.
.



Relevant Pages

  • Re: [OT]: GCC Issue
    ... | libraries with extensions other than `.a'. ... | the archive on the command line, the linker will include the ... | archives multiple times. ... What are Software Patents for? ...
    (comp.lang.c)
  • Re: [OT]: GCC Issue
    ... | libraries with extensions other than `.a'. ... | the archive on the command line, the linker will include the ... | archives multiple times. ... What are Software Patents for? ...
    (alt.comp.lang.learn.c-cpp)
  • Re: [OT]: GCC Issue
    ... > | it is specified on the command line. ... > | the archive on the command line, the linker will include the ... > | archives multiple times. ... > What are Software Patents for? ...
    (comp.lang.c)
  • Re: [OT]: GCC Issue
    ... > | it is specified on the command line. ... > | the archive on the command line, the linker will include the ... > | archives multiple times. ... > What are Software Patents for? ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Typical handling of packages through compilers
    ... It's the lack of a proper smart linking in the GNU linker. ... When you specify these options, ... create larger object and executable files and will also be slower. ...
    (comp.lang.ada)