To check if the program is 64 bit, you can compile it and run
file <name-of-the-binary>
Example:
~> file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
So /bin/ls
is 32 bit on my system.
Whether the code is compiled for 32 bits or 64 bits depends on your environment and your compiler settings. To compile 64 bit programs, you need a 64 bit kernel and a 64 bit "userland" -- in particular a 64 bit version of libc6 and the compiler libraries. Usually, your compiler will just choose the appropriate mode for your environment.
Some Linux distributions offer "mixed" environments: a 64 bit kernel with both 32 bit and 64 bit libraries. If your environment is like this, your compiler might offer compiling both types of binaries. How to choose between them depends on your hardware platform and your compiler. For gcc on the x86-64 platform, the compiler switches would be -m32
and -m64
-- just have a look at the gcc
man page.