Operating System - HP-UX
1753774 Members
7174 Online
108799 Solutions
New Discussion юеВ

Linking in 64-bit mode with aCC

 
SOLVED
Go to solution
Raheel A
Advisor

Linking in 64-bit mode with aCC

Here is my machine specification:-bash-2.05b$ -bash-2.05b$uname -a
HP-UX B.11.00 U 9000/785 2001469948
-bash-2.05b$model
9000/785/C3000
-bash-2.05b$ getconf KERNEL_BITS
64

I am trying to compile some code with aCC and I am getting:

/usr/ccs/bin/ld: : Mismatched ABI. 64-bit PA object file found in 32-bit link.

I have tried with both using +DA2.0w and +DD64 in the compile flags but no use..Is there any flag for the linker as well for 64-bit.

When I pass the -v for verbose as the linker flag, one of the options that it shows is "+nosmartbind" which is 32 bit specific and this is how i know that the linker is messed up..
I also did file on the generated .o files and they are ok..

-bash-2.05b$ file Foo.o
Foo.o: ELF-64 relocatable object file - PA-RISC 2.0 (LP64)

and all the libraries i am using are 64 bit compiled..

7 REPLIES 7
James R. Ferguson
Acclaimed Contributor

Re: Linking in 64-bit mode with aCC

Hi:

The linker uses the first object it finds to decide what "bitness" *every* object must be. All your objects and shared-libraries must be either 64-bit or 32-bit.

Regards!

...JRF...
Raheel A
Advisor

Re: Linking in 64-bit mode with aCC

thanks...but the first object is 64 bit as i indicated in my original post
-bash-2.05b$ file Foo.o
Foo.o: ELF-64 relocatable object file - PA-RISC 2.0 (LP64)

James R. Ferguson
Acclaimed Contributor

Re: Linking in 64-bit mode with aCC

Hi (again):

> but the first object is 64 bit

And, then, EVERY object and shared library must be 64-bit. The first object's bitness determines what the linker wants for every subsequent object.

Regards!

...JRF...
Raheel A
Advisor

Re: Linking in 64-bit mode with aCC

thanks a lot...
yes that is the case, all the other objects and libraries are 64 bit...so if the first object is 64-bit, then it will use the default library search location for 64-bit libraries right?

also how can we explain the fact that i see the "+nosmartbind" in the verbose mode

thanks
Dennis Handly
Acclaimed Contributor
Solution

Re: Linking in 64-bit mode with aCC

You must compile AND link with +DD64.

>one of the options that it shows is "+nosmartbind" which is 32 bit specific

Yes, you haven't told the driver you are doing a 64 bit link.

>JRF: The linker uses the first object it finds to decide what "bitness" *every* object must be.

The first object the driver adds is crt0.0 which would be 32 bit.

>but the first object is 64 bit as I indicated in my original post

No, the first object is what ld sees, not what you put on the driver line.

>if the first object is 64-bit, then it will use the default library search location for 64-bit libraries right?

No, the driver commands the linker to look at what it thinks is the default path.

>how can we explain the fact that I see the "+nosmartbind" in the verbose mode

You need to look at the whole -v output. Providing the output here would have helped.
Raheel A
Advisor

Re: Linking in 64-bit mode with aCC

using DD64 as linker flag worked!!! how come the man page for the linker doesnt mention this flag!!..grrr
Dennis Handly
Acclaimed Contributor

Re: Linking in 64-bit mode with aCC

>using +DD64 as linker flag worked! how come the man page for the linker doesn't mention this flag!

This is NOT a linker option. This is a compiler driver option that you use both when compiling and linking.

Hmm, though it is obvious to me, the documentation doesn't clearly say "compiling AND linking". I'll see if I can beef this up.