Skip to content

Compiling

FMXExpress edited this page Oct 15, 2020 · 1 revision

Compiling a source file

A special feature of Embarcadero Dev-C++ is the ability to compile (and run) single source files. This is done via the following steps:

  • Create (Ctrl+N) or open (Ctrl+O) a source file.
  • Click Compile (F9) to compile the currently visible file.
  • Optionally, run the created executable (F10). This compilation will use the compiler set selected at Tools >> Compiler Options.

Compiling a project

Compiling a project largely requires the same steps:

  • Create (Ctrl+N) or open (Ctrl+O) a project.
  • Click Compile (F9) to apply changes made in a source file.
  • Click Rebuild (F12) to apply changes made in a header file or to recompile all files.
  • Optionally, run the created executable (F10). This compilation will use the compiler set selected at Tools >> Compiler Options, but unlike source file compilations, it will use the compiler settings located at Project >> Project Options >> Compiler.

Tips

  • For single file compilations, make sure to use proper file extensions. When not explicitly telling the compiler which standard to use (using the -std flag), use *.c to compile as C or *.cpp to compile as C++.
  • To reduce compilation output size, especially when using C++ headers, consider passing -s to the compiler. This can be done manually or via (Settings) >> Linker >> Strip executable. This option will remove any unused data from the output. A downside of this option is that debugging and profiling will not work anymore. An alternative but much less effective approach is to reduce the amount of included files.
  • To reduce compilation time, consider including less files. For example, when using a project, don't blindly include every file in every file!
  • To save one click in the compilation process, try out Compile & Run (F11). This will, obviously, compile and run your file or project immediately afterwards.
  • When changing a header file, make sure to recompile all source files that make use of it by rebuilding. Not doing so will lead to undefined executable behaviour: the code you're seeing will not be what will be executed because some source files are making use of outdated headers.
Clone this wiki locally