Exclude Source Files from Build in Eclipse
Join the DZone community and get the full member experience.Join For Free
sometimes i have source files in my project which i do not want to get compiled (or excluded from build). because as i’m using the ‘managed make’, all source files matching certain extensions (like *.c) are automatically included into the build.
to exclude a file from build, i right-click on it to get to the properties. there i can select a check box to have it excluded from the build:
that file gets marked with an icon decorator :
to include it again into the build, simply remove that check mark again.
another way is to use the ‘exclude from build’ context menu which does the same:
here it offers a dialog with the choice of build configurations where i can set a check mark from which build configuration i want to have it excluded:
this applies to all sources files to be compiled (usually *.c, *.cpp, *.cxx) and even linker files (*.ld, …). but what about header files????? the answer is that for header files it does not make any sense to exclude them : they are included by the compiler based on the include path (compiler) settings. so you cannot ‘exclude’ a single header file to be included. what you could do is to remove a path from the compiler settings, but then all header files will not be included.
happy excluding :-)
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.