UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » General
  • » Compiling 32 bit sample program on 64 bit fedora using -m32 option

#1 2009-10-07 01:52 PM

pankajdev
Member
Registered: 2009-07-15
Posts: 14

Re: Compiling 32 bit sample program on 64 bit fedora using -m32 option

I have Fedoara 11 install on my PC. I want to compile program as 32 by g++ option -m32. I have 32 bit library install on my machine which present in path

/usr/lib/gcc/x86_64-linux-gnu/4.4.0/32
and 64 bit library is on path
/usr/lib/gcc/x86_64-linux-gnu/4.4.0

When i compile my sample program with -c & -m32 option it compile correctly
c++ -c -m32 Sample.cpp
but when i am trying to create executable by command
c++ Sample.o -m32 -o Sample
then it gives linking error as

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.0/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.0/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.0/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.0/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status

Can anybody please tell me solution for this problem

Offline

#2 2009-10-07 01:58 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Compiling 32 bit sample program on 64 bit fedora using -m32 option

You don't have a 32-bit libstdc++ installed...  Try "yum install libstdc++.i386" (as root)...

Offline

#3 2009-10-07 02:20 PM

pankajdev
Member
Registered: 2009-07-15
Posts: 14

Re: Compiling 32 bit sample program on 64 bit fedora using -m32 option

i have Fedora 11 thats why i have install these rpm for 32 library
yum install glibc-2.10.1-2.i686.rpm
yum install glibc-devel-2.10.1-2.i586.rpm

I think so it has created library in path
/usr/lib/gcc/x86_64-linux-gnu/4.4.0/32

I have library in both path above one and /usr/lib/gcc/x86_64-linux-gnu/4.4.0/ so i have presume that this /usr/lib/gcc/x86_64-linux-gnu/4.4.0/32
path contain 32 bit library i have tried to link it but still it gives above error

Offline

#4 2009-10-07 11:12 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Compiling 32 bit sample program on 64 bit fedora using -m32 option

I'm telling you, the error message is clearly stating you are missing a 32-bit version
of libstdc++...  You said you installed 32-bit glibc...  That's completely different (but,
probably also necessary)...  If you were compiling a straight C program with gcc,
then you might only need glibc...  But, you're compiling a C++ app with g++, so you
need libstdc++, which is a separate package...  I'm running CentOS 5.3, not Fedora,
but for me the correct command would be the one I gave you: "yum install libstdc++.i386"...
(Note: your example yum commands don't even look right...  Yum does the downloading
for you, so you shouldn't be giving it a downloaded RPM file name...  Just a package
name, and optional architecture...  If you do give it your own downloaded RPM file,
then you instead want "localinstall" not "install"...)

Offline

#5 2009-10-08 06:52 AM

pankajdev
Member
Registered: 2009-07-15
Posts: 14

Re: Compiling 32 bit sample program on 64 bit fedora using -m32 option

Thanks for help ... Now its working .. i have installed respective pakage that you have told.

Offline

#6 2010-01-25 01:04 PM

SepMyperose
Guest

Re: Compiling 32 bit sample program on 64 bit fedora using -m32 option

Do you have kernel sources/kernel headers installed?
I also got this error when I tried compiling the driver without having compiled my kernel. After doing that, and rebooting the driver compile worked fine.

  • Index
  • » General
  • » Compiling 32 bit sample program on 64 bit fedora using -m32 option

Board footer

Powered by FluxBB