Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...)

like image 336
Alex Avatar asked Nov 23 '14 10:11

Alex


1 Answers

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

like image 190
w4rt3r Avatar answered Nov 02 '22 23:11

w4rt3r