General
Showing results for 
Search instead for 
Do you mean 

linking after a gcc compilation

Advisor

linking after a gcc compilation

Hi everyone

Having downloaded and installed the gcc 4.2.3 depot for 11.11 I am having problems linking my very simple initial test program (HelloWorld). If I attempt to compile and link using gcc I see this...

HP-C8000<58> gcc file_type_c++.cpp
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (/var/tmp/ccErrvH3.o)
was detected. The linked output may not run on a PA 1.x system.
/usr/ccs/bin/ld: Unsatisfied symbols:
__gxx_personality_v0 (code)
collect2: ld returned 1 exit status

Whereas if I attempt to split up the process, the compilation procedes without errors but using g++ to link I get this...

HP-C8000<57> g++ file_type_c++.o
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (file_type_c++.o) was
detected. The linked output may not run on a PA 1.x system.
/usr/ccs/bin/ld: Unrecognized argument: +init
/usr/ccs/bin/ld: Usage: /usr/ccs/bin/ld [options] [flags] files
collect2: ld returned 1 exit status

I was surprised to see the gcc depot did not include a GNU ld and it appears this is causing the error. What am I missing. I presume the ld in /usr/bin is that bundled with 11.11 but not sure where the /usr/ccs/bin ld is from?

Thanks in advance for any help you can give.

Ed

8 REPLIES
Honored Contributor Honored Contributor

Re: linking after a gcc compilation

# ll /usr/bin/ld
784 lr-xr-xr-t 1 root sys 15 Jul 23 12:38 /usr/bin/ld -> /usr/ccs/bin/ld


# swlist -l file|grep /usr/ccs/bin/ld
OS-Core.C-KRN: /usr/ccs/bin/ld
OS-Core.CMDS2-AUX: /usr/ccs/bin/ldd
OS-Core.LINKER-PAOBJ: /usr/ccs/pa/usr/ccs/bin/ld
OS-Core.LINKER-PAOBJ: /usr/ccs/pa/usr/ccs/bin/ldd
PHSS_36336.C-KRN: /usr/ccs/bin/ld
PHSS_36336.LINKER-PAOBJ: /usr/ccs/pa/usr/ccs/bin/ld
Acclaimed Contributor Acclaimed Contributor

Re: linking after a gcc compilation

>ld: Unsatisfied symbols: __gxx_personality_v0

You should use g++ to compile AND link C++ sources and gcc only for C.

>ld: Unrecognized argument: +init

I assume what Tim forgot to mention is that you need a newer linker that supports +init.
And that you must use HP's linker tools on HP-UX, not foreign devil tools.
Advisor

Re: linking after a gcc compilation

Tim, Dennis

Thanks for the replies. Interpreting them as i can with a limited knowledge of the technologies in question leads me to more questions.

Tim I presume you are giving me example results from your system. Here is the output from my own system

# ll /usr/bin/ld
lr-xr-xr-t 1 root sys 15 Jun 22 2006 /usr/bin/ld -> /usr/cc
s/bin/ld

# swlist -l file|grep /usr/ccs/bin/ld
OS-Core.C-KRN: /usr/ccs/bin/ld
OS-Core.CMDS-AUX: /usr/ccs/bin/ldd

# ld -V
92453-07 linker command s800.sgs ld PA64 B.11.18 REL 000922
ld: 92453-07 linker linker ld B.11.18 000922
ld: Usage: ld [options] [flags] files

Can you confirm that the PHSS lines in your post refer to linker patches. If this is the case can I download and install them from the HP website?

Dennis you confirm that I need a newer linker. Will patching my existing linker (assuming this is possible) be sufficent?

You also suggest I should be compiling using g++ and linking only using the HP linker. Below is the output from a compile and link using g++ and my existing linker.

HP-C8000<28> g++ -c file_type_c++.cpp
HP-C8000<35> ld file_type_c++.o
ld: (Warning) At least one PA 2.0 object file (file_type_c++.o) was detected. Th
e linked output may not run on a PA 1.x system.
ld: Unsatisfied symbols:
__gxx_personality_v0 (code)
printf (code)
ld: No $UNWIND_END$ subspace has been defined (probably missing /usr/ccs/lib/crt
0.o)

Any further information you can give would be great.

Ed

Honored Contributor Honored Contributor

Re: linking after a gcc compilation

> You should use g++ to compile AND link C++
> sources [...]

> HP-C8000<28> g++ -c file_type_c++.cpp
> HP-C8000<35> ld file_type_c++.o

I could be totally wrong, but I believe that
"use g++ to [...] link" meant that you should
use g++ to link instead of a bare "ld", as
in, for example:

g++ file_type_c++.o

The compiler (driver) knows what exotic
options must be passed to ld. You don't.

Otherwise, it might pay to read the
documentation for g++, where it probably
tells you how to get a program linked.
Advisor

Re: linking after a gcc compilation

With my test program compiling and linking I find I have a 32 bit build. Searching around on the forum suggests this is the default, there is also mention of a switch to invoke 64 bit compilation -mlp64, however this is for itanium and i am working with pa_risc.

Is there an equivalent flag or do I need to download a 64 bit gcc binary?
Acclaimed Contributor Acclaimed Contributor

Re: linking after a gcc compilation

>Dennis you confirm that I need a newer linker. Will patching my existing linker be sufficient?

It will solve that "Unrecognized argument: +init" error.

>You also suggest I should be compiling using g++ and linking only using the HP linker.

My point was only that you should not use GNU's ld.

>I need to download a 64 bit gcc binary?

You would have to download it from:
http://www.hp.com/go/gcc
Advisor

Re: linking after a gcc compilation

32 and 64 bit builds up and running.
Thanks again for your help and patience.
Highlighted
Advisor

Re: linking after a gcc compilation

solved