C/C++/Fortran Projects and Makefiles

See Also 

Before you begin developing C, C++, or Fortran applications in the IDE, you should be familiar with the following concepts:

Projects

A C or C++ or Fortran project is a group of source files and associated information about how to compile and link the source files and run the resulting program. The IDE stores project information in a project folder that includes a makefile and metadata files. Your source directories do not need to be physically located in the project folder.

In the IDE, you always work inside a project even if your program is contained in a single source file. Each project must have a makefile so the IDE can build the project. A project's makefile can be generated by the IDE or you can use a makefile that was previously created outside the IDE. Projects with IDE-generated makefiles are called managed projects.

You can also create projects from existing sources that already include a makefile, or that build a makefile when you run configure scripts. This type of project is called an unmanaged project.

You work with projects through the IDE's Projects window. See IDE Tools for C and C++ Development for more information.

Makefiles

A makefile is a file of shell commands that the make utility uses. The make utility is a program that is provided independently of the IDE, often with the tool collection along with the compilers. Typically, the make utility uses the makefile to determine which portions of a program to compile, but there are other uses also.

The C and C++ project system is built directly on top of the make utility. All of the project commands, like Build or Run, run make to call targets in the project's makefile. You can therefore build and run your C, C++, or Fortran project outside the IDE by running make, the same way the IDE builds and runs your project.

You do not need to know the make utility to work with the IDE. For a managed C/C++ Application, Dynamic Library, or Static Library project, you can set all the basic compilation and runtime options in the project's Project Properties dialog box and the IDE automatically updates your project's makefile. If you know how to work with makefiles, you can customize a project's makefile or write your own makefile for your project. You can also create a makefile with the Makefile wizard in the IDE.

An unmanaged project with an existing makefile might use a configure script. Configure scripts detect information about the system on which you are running, and use the information to generate a makefile that is tailored to the system.

For an unmanaged project, the makefile is not updated when you set project properties in the IDE. To change a makefile that was created outside the IDE, you must edit the makefile manually or run a script to recreate the makefile.

If an unmanaged project has a configure script, a qmake *.pro script, or CMakeLists.txt script, the script is run during project creation to create the makefile. After the project is created, if you need to change the makefile, you can rerun the project's script from the command line. If you prefer to work within the IDE, you can reconfigure the project by right-clicking the project node and selecting Code Assistance > Reconfigure Project... The IDE will run the project's script to regenerate the makefile, and do a clean build of the project.

If the project is a qmake or cmake project, you can edit the *.pro or CMakeLists.txt file before reconfiguring if you want.

See also
IDE Tools for C and C++ Development
About C and C++ Projects
Creating a Makefile

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.