LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Compiling 32 bit sample program on 64 bit fedora using -m32 option (http://www.linuxquestions.org/questions/linux-newbie-8/compiling-32-bit-sample-program-on-64-bit-fedora-using-m32-option-760268/)

pankajdev 10-07-2009 05:20 AM

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

weibullguy 10-07-2009 05:28 AM

You have to explicitly tell the linker to use the libstdc++ in /usr/lib/gcc/x86_64-linux-gnu/4.4.0/32.

pankajdev 10-07-2009 07:42 AM

How can i explicitly tell linker. I have set that path in LD_LIBRARY_PATH as well as i have given it in -L option while compiling it still it gives same error.


All times are GMT -5. The time now is 09:43 PM.