GCC: Compiling C Programs to produce 32 and 64 bit Binaries

by prashere
GNU/Linux ◆ xterm-256color ◆ bash 2145 views

GCC expanded as Gnu Compiler Collection is a Free Software Multi language Compiler collection that follows the ANSI Standards.

Here in this Terminal Cast, I show you how to compile a simple hello-world program and produce binary for both 32 and 64 bit machine. My computer is an 64 bit machine, so I can produce 64 bit as well as 32 bit binary, but if your machine is 32 bit machine, you can only produce binary for 32 bit architecture.

Also please note that I have installed gcc-multilib in order to generate binary for multiple architecture. If you have just gcc, you cannot use the -m flag that I have used above.


./output32

  • . (dot) in the above shell command denotes the current folder.
  • / (slash) denotes the path of this current folder / directory.
  • output32 is the name of the binary executable.

I prefer and use vim as my text editor. You can use any text editor of your choice. Some common text editors that comes by default in GNU/Linux distributions,

  • gedit (Graphical Text Editor similar to Notepad and has more features like syntax highlighting, etc.,)
  • nano
  • vi (vim is vi improved)