Creating your makefile

For the purpose of this tutorial, you were instructed to create a Standard Make C++ Project which requires you to create a makefile. Managed Make C/C++ projects generate makefiles for you.

To create your makefile:

  1. In the C++ Projects view, right-click the HelloWorld project folder and select New > File.
  2. In the File name box, type makefile.
  3. Click Finish.
  4. Type the gnu make instructions below in the editor. Lines are indented with tab characters, not with spaces.

  5. all: hello.exe

    clean:
        rm main.o hello.exe

    hello.exe: main.o
        g++ -g -o hello main.o

    main.o:
        g++ -c -g main.cpp
     

  6. Click File > Save.

Your new makefile, along with your main.cpp file are displayed in the C/C++ Projects view and in the Navigator view. Your project now contains main.cpp and makefile. You can now build your HelloWorld project.

Next: Building your project

Back: Creating your C++ file

Related concepts
Project
Code entry

Related tasks
Working with C/C++ project files
Writing code

Related reference
C/C++ Projects view

IBM Copyright Statement