hello_linux_world.c

// ===========================================================
// title   : hello_linux_world.c (a.k.a. hello-world.c)
// created : 2022-08-04
// author  : Neil Rieck (Waterloo, Ontario, Canada)
// OS      : RedHat, CentOS, RockyLinux on x86-64
// builds  :
// 1) gcc      hello_linux_world.c -o hello_linux_world64 # native
// 2) gcc -m32 hello_linux_world.c -o hello_linux_world32 # optional
// prep    :
// 1) both builds require gcc development tools so do this:
//    yum grouplist                           # view choices
//    yum -y groupinstall 'Development Tools' # if required 
// 2) build-2 (hackers only) requires i686 support so do this:
//    yum install glibc-devel.i686 \
//                libgcc.i686 \
//	          libstdc++-devel.i686 \
//	          ncurses-devel.i686
// 3) once build-2 works properly you will then be able to do
//    a "32-bit only" build of WINE (Windows Emulator).
//    Visit https://winehq.org for more details
// ===========================================================
#include <stdio.h>
    int count;
    printf("Hello World from program: %s\n", argv[0]);
    printf("cli argc %d\n", argc);
    for (count=0; count<argc; count++){
	printf("cli arg  %d %s\n", count, argv[count]);
    }
    printf("adios\n");
    return 0;
}

Build + Test

<sr> $
<ur> gcc      hello_linux_world.c -o hello_linux_world64 # native
<sr> $
<ur> gcc -m32 hello_linux_world.c -o hello_linux_world32 # optional
<sr> $
<ur> ls -la hello*
<sr> -rwxr-xr-x. 1 neil admgrp 7264 Aug  6 10:32 hello_linux_world32
     -rwxr-xr-x. 1 neil admgrp 8424 Aug  6 10:32 hello_linux_world64
     -rw-r--r--. 1 neil admgrp 1258 Aug  6 10:32 hello_linux_world.c
     $
<ur> ./hello_linux_world32 one two
<sr> Hello World from program: ./hello_linux_world32
     cli argc 3
     cli arg  0 ./hello_linux_world32
     cli arg  1 one
     cli arg  2 two
     adios
     $
<ur> ./hello_linux_world64 three four
<sr> Hello World from program: ./hello_linux_world64
     cli argc 3
     cli arg  0 ./hello_linux_world64
     cli arg  1 three
     cli arg  2 four
     adios
     $

left hand Back to Linux Demo Index
home Back to Home
Neil Rieck
Waterloo, Ontario, Canada.