Create the initial command line application

To create a basic Hello World command line application we need to:

  • Create a directory under the main repository directory like HelloWorld

  • Create main.cpp file with the C++ source code.

  • Create a makefile that tells our build system how to compile it

  • Compile and run it

This is an example main.cpp:

//--------------------------------------------------------------------------- // Copyright (C) 1997-2021 iNTERFACEWARE Inc. All Rights Reserved // // Module: main.cpp // // Description: // // An example command line app // // Author: Eliot Muir //--------------------------------------------------------------------------- #include <COL/COLostream.h> #include <stdlib.h> int main(int argc, const char** argv){ COLcout << "Hello world!" << newline; return EXIT_SUCCESS; }

The first include COL/COLostream which behaves very similarly to the standard ostream from the standard C++ library. The stdlib.h include gives us EXIT_SUCCESS.

There is a line which prints “Hello World!”.

This is the content of the makefile:

TARGET=HelloWorld DIRS=\ COL include ../make/makefile.core
  • The first line tells the make system to build a command line executable program called HelloWorld

  • The DIRS variable has the list of libraries that will be compiled and linked together to make the executable.

  • The include line pulls in the machinery that is required to make the build actually work across the different platforms we work with.