Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why are different linkers used by C compiler vs other compilers

807575May 30 2007 — edited Sep 20 2007
I have installed Sun Studio 11 on our Linux machine and I am trying to use it to
compile programs of different languages. Prior to running, I set my PATH and
LD_LIBRARY_PATH to point to the software installation area as shown below.

setenv PATH /home/me/linux/SUNWspro/sunstudio12/bin:/home/me/linux/SUNWspro/sunstudio12/prod/lib:${PATH}
setenv LD_LIBRARY_PATH /home/me/linux/SUNWspro/sunstudio12/prod/lib

I then notice that if I compile with the C compiler, it uses the linker in /usr/bin/ld
but if I use the C++, f77, or F90, they use the linker from my PATH,
/home/me/linux/SUNWspro/sunstudio12/prod/lib.

Normally, I do not care about this behavior but I am trying to pass a consistent set
of flags for all 4 cases, but with different linkers, this does not work. Specifically, I
have this set of flags for the C compiler.

"-Wl,--export-dynamic"

But, the other 3 compilers choke on this and get a warning like this:

CC: Warning: Option -Wl,--export-dynamic passed to ld, if ld is invoked, ignored otherwise
/home/me/linux/SUNWspro/sunstudio12/prod/lib/ld: unrecognized option '-Wl,--export-dynamic'
/home/me/linux/SUNWspro/sunstudio12/prod/lib/ld: use the --help option for usage information

I guess my question is why are different linkers used?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2007
Added on May 30 2007
5 comments
226 views