building 32-bit on 64-bit system

A

Andrey Rusanov

Hi,

i have 64-bit linux (arch) and i'm trying to build 32-bit application.

application is "emtyapp.cpp" file, listed below:
"
#include <cstdio>
int main ()
{
printf("hello world\n");
return 0;
}
"

my build command is:
"
g++ -m32 -nostdlib -L/opt/lib32/lib -L/opt/lib32/usr/lib -L/opt/lib32/
usr/lib/gcc/i686-pc-linux-gnu/4.4.3 emtyapp.cpp
"

but building failed and output is:
"
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to
0000000008048094
/tmp/ccydsmUH.o: In function `main':
emtyapp.cpp:(.text+0x11): undefined reference to `puts'
/tmp/ccydsmUH.o:(.eh_frame+0x12): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
"

So i need help:
how to build it? or what is more specific group for 32-64-cross-
compiling ?
 
P

Puppet_Sock

So i need help:
how to build it? or what is more specific group for 32-64-cross-
compiling ?

You need something connected with your compiler, or possibly
with your operating system.

groups.google.com is a good place to start. Try searching
for some of your key concepts in the comp.* heirarchy.
Hey, maybe your question has already been answered.
Sock
 
R

Rolf Magnus

Andrey said:
Hi,

i have 64-bit linux (arch) and i'm trying to build 32-bit application.

application is "emtyapp.cpp" file, listed below:
"
#include <cstdio>
int main ()
{
printf("hello world\n");
return 0;
}
"

my build command is:
"
g++ -m32 -nostdlib -L/opt/lib32/lib -L/opt/lib32/usr/lib -L/opt/lib32/
usr/lib/gcc/i686-pc-linux-gnu/4.4.3 emtyapp.cpp
"

but building failed and output is:
"
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to
0000000008048094
/tmp/ccydsmUH.o: In function `main':
emtyapp.cpp:(.text+0x11): undefined reference to `puts'
/tmp/ccydsmUH.o:(.eh_frame+0x12): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
"

I would suspect that this happens because you explicitly tell the linker to
not link against the standard library.
 
V

Victor Bazarov

You need something connected with your compiler, or possibly
with your operating system.

groups.google.com is a good place to start. Try searching
for some of your key concepts in the comp.* heirarchy.
Hey, maybe your question has already been answered.

And to add (or narrow it down a bit for Andrey), there are newsgroups
for Linux (comp.os.linux.development.*) and for GCC (gnu.gcc.*), might
help if a GCC/Linux specific question is posted there.

Good luck!

V
 
B

Bart van Ingen Schenau

Hi,

i have 64-bit linux (arch) and i'm trying to build 32-bit application.

application is "emtyapp.cpp" file, listed below:
"
#include <cstdio>
int main ()
{
    printf("hello world\n");
    return 0;}

"

my build command is:
"
g++ -m32 -nostdlib -L/opt/lib32/lib -L/opt/lib32/usr/lib -L/opt/lib32/
usr/lib/gcc/i686-pc-linux-gnu/4.4.3 emtyapp.cpp
"

but building failed and output is:
"
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to
0000000008048094
/tmp/ccydsmUH.o: In function `main':
emtyapp.cpp:(.text+0x11): undefined reference to `puts'
/tmp/ccydsmUH.o:(.eh_frame+0x12): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
"

So i need help:
how to build it? or what is more specific group for 32-64-cross-
compiling ?

The complaints are all about things that would normally be located in
the standard library.
Try recompiling your program without the '-nostdlib' option.

Bart v Ingen Schenau
 
A

Andrey Rusanov

The complaints are all about things that would normally be located in
the standard library.
Try recompiling your program without the '-nostdlib' option.

Bart v Ingen Schenau

no, without '-nostdlib' output is:
"
/usr/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /
lib/libc.so.6
/usr/bin/ld: cannot find /lib/libc.so.6
collect2: ld returned 1 exit status
"
 
B

Bart van Ingen Schenau

no, without '-nostdlib' output is:
"
/usr/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /
lib/libc.so.6
/usr/bin/ld: cannot find /lib/libc.so.6
collect2: ld returned 1 exit status
"

Then either you don't have a 32-bit version of libc (the standard
library) on your system, or the linker does not know to look for it in
the correct places.
This is most definitely the time to take this question to a GCC group.

Bart v Ingen Schenau
 
P

Paul Bibbings

Andrey Rusanov said:
no, without '-nostdlib' output is:
"
/usr/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /
lib/libc.so.6
/usr/bin/ld: cannot find /lib/libc.so.6
collect2: ld returned 1 exit status
"

There is either something broken in your installation ("incompatible
/lib/libc.so.6") or, having removed -nostdlib from your option list,
what remains - i.e., the -L options - is incorrect for your
installation. In either case, this is not an issue with the language
and, as such, should really be taken up in a forum or mailing list that
discusses such issues for your particular compiler. I think some have
been suggested already.

To give a hint here merely (although offtopic), it seems that you added
-nostdlib in an attempt to get around the initial error posted above.
This merely distracted you and the error you need to deal with directly
is why your compiler is trying to pick up an "incompatible
/lib/libc.so.6" and then - quite rightly, as it is incompatible -
rejecting it.

If your attempts to `correct' errors lead merely to more (and/or
different) errors, go back to the first, as your `correction' is almost
certainly a red-herring.

Regards

Paul Bibbings
 
R

red floyd

There is either something broken in your installation ("incompatible
/lib/libc.so.6") or, having removed -nostdlib from your option list,
what remains - i.e., the -L options - is incorrect for your
installation.  In either case, this is not an issue with the language
and, as such, should really be taken up in a forum or mailing list that
discusses such issues for your particular compiler.  I think some have
been suggested already.

To give a hint here merely (although offtopic), it seems that you added
-nostdlib in an attempt to get around the initial error posted above.
This merely distracted you and the error you need to deal with directly
is why your compiler is trying to pick up an "incompatible
/lib/libc.so.6" and then - quite rightly, as it is incompatible -
rejecting it.

Paul is correct, but I'll be even more explicit... What the heck
did you expect when you explicitly told the linker to use 32-bit
libraries?
 
J

Jorgen Grahn

....


Paul is correct, but I'll be even more explicit... What the heck
did you expect when you explicitly told the linker to use 32-bit
libraries?

What did *you* expect? He told his compiler to generate 32-bit code,
and link with 32-bit libraries. He's not a moron for expecting that to
work. (Although there may be good reasons why it won't work, they
aren't of the "I'm a moron" kind.)

(For a free OS like Linux, I'd compile in the native environment, on a
throwaway machine, or in a VM. Cross-compiling has always seemed like
more trouble than it's worth to me.)

/Jorgen
 
R

red floyd

What did *you* expect?  He told his compiler to generate 32-bit code,
and link with 32-bit libraries. He's not a moron for expecting that to
work. (Although there may be good reasons why it won't work, they
aren't of the "I'm a moron" kind.)

Oops. And that's why you post compiler-specific questions on a
compiler
specific forum. Because then you get answers from people who know
what
all the options mean...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top