How do I compile 64bit program with gcc/g++ on a 64bit Linux?

I'm using Ubuntu 10.04 LTS, and want to make a program to run on a large Debian server that has 300GB memory. With command:

g++ Encoder.cpp -std=c++0x -m64 -o Encoder.o

it returns something like

In files included from /usr/include/features.h:378, from /usr/include/c++/4.4/i486-linux-gnu/64/bits/os_defines.h:39 from /usr/include/c++/4.4/i486-linux-gnu/64/bits/c++confige.h:243, from /usr/include/c++/4.4/iostream:39, from Encoder.cpp:1:
/usr/include/gnu/stubs.h:9:27: error: gnu/stubs-64.h: No such file or directory

but without the -m64 flag, the program is compilable, but will run into "segmentation fault" problem whenever RAM usage is over about 2.5GB.

Or would actually the default compilation be 64bit? How do I tell if a process is 32bit or 64bit in "top"?

2

2 Answers

The glibc-devel package should be correct, however, be sure to use the x86_64 arch package.

In my fedora, glibc-devel.x86_64 was the correct package.

For ubuntu, it might be simply glibc-dev.x86_64

Try one of the following

sudo apt-get install glibc-devel.x86_64
sudo apt-get install glibc-dev.x86_64

It looks you're missing the glibc-devel package that carries gnu/stubs-64.h. Try:

sudo apt-get install glibc-devel

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like