Alex
Alex

Reputation: 44405

How to exclude a source file from being build in eclipse (C++)?

I am trying to follow some insane complicated steps in order to be able to create C++ unit-tests for C++ code in eclipse (I am utterly new to eclipse). These steps state to exclude some source files from using in the built - which makes sense to me. However, in my eclipse I do not see any Exclude from built option when right-clicking on the source file. Also, neither this answer nor this answer do work, as I do not see the mentioned options in the list of things when I right-click on the source file.

So how to exclude a source file from a built?

P.S. The Version of eclipse seems to be Luna 4.4.0.

(Or, even better: If anyone knows an easier way to set up eclipse with ANY unit-testing framework in a SIMPLE way,- or knows a different Linux framework to start developing C++ projects with unit-testing right away without trying to set up things in unknown and complicated ways for weeks before starting to actually code something - ideas are VERY VERY welcome...)

Upvotes: 5

Views: 15216

Answers (4)

Johan Iskandar
Johan Iskandar

Reputation: 41

Project Properties> C/C++ General> Path and Symbols

Tab Source Location

Select the source folder

Click the Edit Filter button

Add the file you want to exclude

Upvotes: 3

Carlos
Carlos

Reputation: 356

I am using MARS eclipse version.

You have to create a build configuration for each component you are building. Here is how to do that: multiple_execs

Then for each source file that you do not want included in that build; you right click on that source file and then select Resource Configuration and select Exclude From Build. Then you check the box of the build configuration you created above that you do not want the source a part of. Here is YouTube video showing this: exclude files from a build

Upvotes: 0

Clyde
Clyde

Reputation: 93

I've tried this and it worked on Eclipse: Right Click the file > Properties ... > Resource > Attributes : Derived.

(Eclipse Indigo) Hope that helps.

Upvotes: 0

w4rt3r
w4rt3r

Reputation: 196

I ran into a similar problem.

The C/C++ perspective of Eclipse Luna (4.4) is missing the contextual menu "Exclude from build".

I solve my problem by using the java perpective:

  1. Window -> Open Perspective -> Other... -> Java(default)
  2. Navigate to the file/folder you want to exclude
  3. Right Click -> Resource -> Exclude from build

Then you can switch back to the C/C++ CDT perspective

Upvotes: 6

Related Questions