Lesson 2: Compiling our program


In this lesson we'll add the entry point function that we learnt about in the first lesson of this project to our newly created cpp file. Then we will compile it and see the program that's produced.

So first we open up the file we created last lesson in our text editor, add copy the entry point function into it, which is:

int main(int argc, char **argv) {
  return 0;
}

So our file should look something like this:

Now we make sure we save it, then hop over to your command prompt. Then cd into the directory this file is in. In my case it's in C:\Users\olive\mycode. Once we are in the directory we can now run our compiler. Like we learnt in lesson 2 of setting up, we are going to use the command to run the compiler.

Windows:

cl myFirstFile.cpp

Mac:

gcc myFirstFile.cpp

To Previous Lesson
To Next Lesson