f



64-bit / 32-bit compilation

Hi Everyone,

Many a times, while trying to compile software from source, I face the
situation where the 32-bit based code tries to access a 64-bit library
of 64-bit executable. In such a situation, I get an "Wrong ELF class"
error. Is there anyway I can compile that 64-bit library or executable
so that my 32-bit code can also use it. Is this what is known as cross-
compilation?

My environment is:

Solaris 10 5/08 s10x_u5wos_10 X86.
CC: Sun C++ 5.8 Patch 121018-15 2008/05/14
GNU Make 3.81
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.489

Thanks & Regards,
dotyet
0
dot
8/1/2008 6:16:51 PM
comp.unix.solaris 26025 articles. 2 followers. Post Follow

8 Replies
1179 Views

Similar Articles

[PageSpeed] 44

In article <8a34ee05-c4eb-464b-94d0-9d4f9632f3f7@c65g2000hsa.googlegroups.com>,
	dot.yet@gmail.com writes:
> Hi Everyone,
> 
> Many a times, while trying to compile software from source, I face the
> situation where the 32-bit based code tries to access a 64-bit library
> of 64-bit executable. In such a situation, I get an "Wrong ELF class"
> error. Is there anyway I can compile that 64-bit library or executable
> so that my 32-bit code can also use it.

No.

> Is this what is known as cross-compilation?

No.

The convention is to put your 64 bit libraries down one extra
directory level from the 32 bit library, in a directory called
amd64. 

-- 
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]
0
andrew
8/1/2008 6:53:05 PM
So, that means I will have to modify the LD_LIBRARY_PATH variable,
each time I do a compilation.

I believe the name amd64 is by convention only?

Thanks Andrew.

Regards,
dotyet


On Aug 1, 2:53=A0pm, and...@cucumber.demon.co.uk (Andrew Gabriel) wrote:
> In article <8a34ee05-c4eb-464b-94d0-9d4f9632f...@c65g2000hsa.googlegroups=
..com>,
> =A0 =A0 =A0 =A0 dot....@gmail.com writes:
>
> > Hi Everyone,
>
> > Many a times, while trying to compile software from source, I face the
> > situation where the 32-bit based code tries to access a 64-bit library
> > of 64-bit executable. In such a situation, I get an "Wrong ELF class"
> > error. Is there anyway I can compile that 64-bit library or executable
> > so that my 32-bit code can also use it.
>
> No.
>
> > Is this what is known as cross-compilation?
>
> No.
>
> The convention is to put your 64 bit libraries down one extra
> directory level from the 32 bit library, in a directory called
> amd64.
>
> --
> Andrew Gabriel
> [email address is not usable -- followup in the newsgroup]

0
dot
8/1/2008 7:01:25 PM
In article <b673a0eb-1b1e-4b33-847e-20a5fb6e7823@f63g2000hsf.googlegroups.com>,
	dot.yet@gmail.com writes:
> So, that means I will have to modify the LD_LIBRARY_PATH variable,
> each time I do a compilation.

No. Use the -L and -R command line options.
I also often add a -i to tell the compiler tools to
ignore any LD_LIBRARY_PATH setting the user has got set.

Having LD_LIBRARY_PATH set in your environment is evil
and you shouldn't do it.

> I believe the name amd64 is by convention only?

In the case of libraries, yes, but in the case of binaries,
no because it's the name of the 64 bit x86 instruction set
(on AMD and Intel), and is used by /usr/lib/isaexec to find
the right binary when multiple versions are available.

-- 
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]
0
andrew
8/1/2008 7:19:24 PM
On 2008-08-01 20:01:25 +0100, dot.yet@gmail.com said:

> 
> So, that means I will have to modify the LD_LIBRARY_PATH variable,
> each time I do a compilation.

The ld(1) man page says the -L and -R linker flags are recommended over 
LD_LIBRARY_PATH. You could also look at embedding dynamic tokens like 
$ISALIST into the runpath.

> I believe the name amd64 is by convention only?

I think it is normal to use one of the values of isainfo.

You should read the Linker and Libraries Guide at docs.sun.com. It 
explains all about this stuff.

Cheers,

Chris

0
Chris
8/1/2008 7:23:27 PM
So, correct me if I am missing something here. Technically, I can't
compile 32-bit code against a 64-bit library. If I don't have the 32-
bit version of the library, I am toast. My only option at that point
is to create a 64-bit version application. Thanks in advance.

Regards,
Dotyet



On Aug 1, 3:23=A0pm, Chris Ridd <chrisr...@mac.com> wrote:
> On 2008-08-01 20:01:25 +0100, dot....@gmail.com said:
>
>
>
> > So, that means I will have to modify the LD_LIBRARY_PATH variable,
> > each time I do a compilation.
>
> The ld(1) man page says the -L and -R linker flags are recommended over
> LD_LIBRARY_PATH. You could also look at embedding dynamic tokens like
> $ISALIST into the runpath.
>
> > I believe the name amd64 is by convention only?
>
> I think it is normal to use one of the values of isainfo.
>
> You should read the Linker and Libraries Guide at docs.sun.com. It
> explains all about this stuff.
>
> Cheers,
>
> Chris

0
dot
8/1/2008 8:10:24 PM
dot.yet@gmail.com wrote:

[please don't top-post]

> On Aug 1, 3:23 pm, Chris Ridd <chrisr...@mac.com> wrote:
>> On 2008-08-01 20:01:25 +0100, dot....@gmail.com said:
>>
>>
>>
>>> So, that means I will have to modify the LD_LIBRARY_PATH variable,
>>> each time I do a compilation.
>> The ld(1) man page says the -L and -R linker flags are recommended over
>> LD_LIBRARY_PATH. You could also look at embedding dynamic tokens like
>> $ISALIST into the runpath.
>>
>>> I believe the name amd64 is by convention only?
>> I think it is normal to use one of the values of isainfo.
>>
>> You should read the Linker and Libraries Guide at docs.sun.com. It
>> explains all about this stuff.
>>
> So, correct me if I am missing something here. Technically, I can't
> compile 32-bit code against a 64-bit library. If I don't have the 32-
> bit version of the library, I am toast. My only option at that point
> is to create a 64-bit version application. Thanks in advance.
>
Correct and don't forget NOT to use LD_LIBRARY_PATH!

-- 
Ian Collins.
0
Ian
8/1/2008 11:44:55 PM
dot.yet@gmail.com wrote:
> So, correct me if I am missing something here. Technically, I can't
> compile 32-bit code against a 64-bit library. If I don't have the 32-
> bit version of the library, I am toast. My only option at that point
> is to create a 64-bit version application. Thanks in advance.

Yes. It is physically, conceptually, impossible to use 32- and 64-bit 
code within the same process space whether the binding happens at link 
or run time. This is not a missing feature or something that could 
someday be "fixed"; it just cannot happen, at least on any system which 
uses ELF.

A. Silk
0
Ambrose
8/2/2008 2:10:59 AM
On 2008-08-02 03:10:59 +0100, Ambrose Silk <silky@no.such.domain> said:

> dot.yet@gmail.com wrote:
>> So, correct me if I am missing something here. Technically, I can't
>> compile 32-bit code against a 64-bit library. If I don't have the 32-
>> bit version of the library, I am toast. My only option at that point
>> is to create a 64-bit version application. Thanks in advance.
> 
> Yes. It is physically, conceptually, impossible to use 32- and 64-bit 
> code within the same process space whether the binding happens at link 
> or run time. This is not a missing feature or something that could 
> someday be "fixed"; it just cannot happen, at least on any system which 
> uses ELF.

The Linker and Libraries Guide answers this question too. Seriously 
(OP) it is worth a read.

Cheers,

Chris

0
Chris
8/2/2008 5:11:31 AM
Reply: