ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am running Linux Red Hat 5 64bit OS and I am trying to work out how to compile 32 bit c++ apps on this 64 bit OS.
I have a simple helloworld app that compiles and runs with default compilation :
g++ test.cpp -> produces a.out that runs without issue
Now I am trying to get it to build in 32bit mode using -m32
and I get the following error:
g++ -m32 test.cpp
In file included from /usr/include/features.h:352,
from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/os_defines.h:39,
from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/c++config.h:39,
from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iostream:43,
from test.cpp:1:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
I think it may be a problem because it looks like there may be no 32 bit C++ libs / headers installed
The only directory under /usr/lib/gcc is x86_64-redhat-linux
I know for a fact that various operating systems (not just talking about linux ones) have either only support for the 64-bit environment, support both 64/32-bit, or for 32-bit only. Ubuntu, to my latest knowledge, has a 64-bit version but which cannot run 32-bit binaries. Gentoo's 64-bit versions indeed have support for the 32-bit libraries (my install has /usr/lib32 and /usr/lib64 for each group).
I just compiled and ran this file on my gentoo box:
Code:
[alex@suicide temp]$ gcc --version
gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.1)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[alex@computer temp]$ cat test.c
#include <stdio.h>
int main() {
printf( "works\n" );
}
[alex@computer temp]$ gcc test.c -o test64
[alex@computer temp]$ gcc -m32 test.c -o test32
[alex@computer temp]$ file test64
test64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), not stripped
[alex@computer temp]$ file test32
test32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), not stripped
[alex@computer temp]$ ./test64
works
[alex@computer temp]$ ./test32
works
Try to see if you can do this with a simple C file like I did (they use fewer headers). If that doesn't work, I'd look to see if you can install packages from the repository that are the 32-bit libraries.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.