The Quick and Dirty "Hello World" with GCC: Difference between revisions
No edit summary |
mNo edit summary |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
By [[User:Martini|Martin Iturbide]] | |||
I just wanted to check out which will be the most basic example to use the | I just wanted to check out which will be the most basic example to use the GNU C compiler to create on OS/2-eCS the most basic, most easy program on earth, the "Hello World" program. | ||
==Preparing the Development | ==Preparing the Development Environment== | ||
First I installed with [http://www.os2world.com/wiki/index.php/Arca_Noae_Package_Manager | First, I installed with [http://www.os2world.com/wiki/index.php/Arca_Noae_Package_Manager Arca Noae Package Manager] the GNU C compiler listed as "gcc". | ||
[[Image:gcc-ANPM.png|400px]] | [[Image:gcc-ANPM.png|400px]] | ||
I also followed the advice on how to install the development environment from the VBOX porting project [http://trac.netlabs.org/vbox]. It | I also followed the advice on how to install the development environment from the VBOX porting project [http://trac.netlabs.org/vbox]. It lists to install the following: | ||
yum install ash which kbuild gcc gcc-wlink gettext-devel pthread-devel libxml2-devel libxslt-devel | yum install ash which kbuild gcc gcc-wlink gettext-devel pthread-devel libxml2-devel libxslt-devel | ||
openssl-devel libcurl-devel zlib-devel libpng-devel libqt4-devel libidl-devel libvncserver-devel | openssl-devel libcurl-devel zlib-devel libpng-devel libqt4-devel libidl-devel libvncserver-devel | ||
nasm libpoll-devel libaio-devel | nasm libpoll-devel libaio-devel | ||
So I installed all that packages. They are not all required for this example, but since I'm starting with this, it is good enough for me. | |||
So I installed all that packages | |||
==Coding the Program== | ==Coding the Program== | ||
I created a simple text file called "hello.c" and included on it. | I created a simple text file called "hello.c" and included on it. | ||
<code> | |||
/* Hello World program */ | /* Hello World program */ | ||
#include<stdio.h> | #include <stdio.h> | ||
main() | main() | ||
Line 27: | Line 25: | ||
printf("Hello World"); | printf("Hello World"); | ||
} | } | ||
</code> | |||
The most simple program to print out "Hello World" on the command prompt. | |||
==Compiling the Program== | |||
To compile and link, it is as simple as: | |||
==Compiling | |||
To compile it is as simple as: | |||
gcc -o hello.exe hello.c | gcc -o hello.exe hello.c | ||
The -o file parameter of gcc is just to place the output of the compilation into a specific file name. | |||
It will generate a "hello.exe" file. | |||
It will generate a "hello.exe" file. | |||
==Testing the Program== | ==Testing the Program== | ||
When you run it you will see: | When you run it, you will see: | ||
[[image:Hellocmd.png|300px]] | [[image:Hellocmd.png|300px]] | ||
Line 48: | Line 44: | ||
[[Image:HelloC-PMDLL.png|500px]] | [[Image:HelloC-PMDLL.png|500px]] | ||
This means that for this program to work it requires that LIBC066.DLL and GCC1.DLL must be installed (on the LIBPATH) of the OS/2-eCS machine where you are running this program. | This means that for this program to work, it requires that LIBC066.DLL and GCC1.DLL must be installed (on the LIBPATH) of the OS/2-eCS machine where you are running this program. | ||
It can not be more simple. | It can not be more simple. | ||
[[Category:Languages Articles]] | [[Category:Languages Articles]] |
Latest revision as of 23:45, 29 July 2022
I just wanted to check out which will be the most basic example to use the GNU C compiler to create on OS/2-eCS the most basic, most easy program on earth, the "Hello World" program.
Preparing the Development Environment
First, I installed with Arca Noae Package Manager the GNU C compiler listed as "gcc".
I also followed the advice on how to install the development environment from the VBOX porting project [1]. It lists to install the following:
yum install ash which kbuild gcc gcc-wlink gettext-devel pthread-devel libxml2-devel libxslt-devel openssl-devel libcurl-devel zlib-devel libpng-devel libqt4-devel libidl-devel libvncserver-devel nasm libpoll-devel libaio-devel
So I installed all that packages. They are not all required for this example, but since I'm starting with this, it is good enough for me.
Coding the Program
I created a simple text file called "hello.c" and included on it.
/* Hello World program */
#include <stdio.h>
main()
{
printf("Hello World");
}
The most simple program to print out "Hello World" on the command prompt.
Compiling the Program
To compile and link, it is as simple as:
gcc -o hello.exe hello.c
The -o file parameter of gcc is just to place the output of the compilation into a specific file name.
It will generate a "hello.exe" file.
Testing the Program
When you run it, you will see:
Let's also check out with PMDLL which DLLs are associated to this newly created hello.exe program.
This means that for this program to work, it requires that LIBC066.DLL and GCC1.DLL must be installed (on the LIBPATH) of the OS/2-eCS machine where you are running this program.
It can not be more simple.