23

I'm doing a C++ project with eclipse CDT but It takes a lot of time building all the source files.

I'd prefer just build the one source file which I'm working with until it's correct and later go ahead to the next source file. But all the options I have seen of eclipse (Make project and Build all), work over all the source files of the project.

Is there any easy way to build just one or two source files in eclipse CDT?

Thank you!

1

2 Answers 2

28

It was much easier than expected.

  1. Deselect Project -> Build Automatically
  2. Right click on the file you want to build
  3. Click on Build Selected File(s).

Source: http://www.cesareriva.com/single-file-compile-in-eclipse-cdt/

2
  • 1
    doesn't work for me either, it's Oxygen.3a. After I did step 1, the build selected file option is in grey (disabled)
    – user21
    May 5, 2018 at 23:47
  • Works here, Eclipse Version: 2020-03 (4.15.0). I'd suggest step 4 to do a shortcut: Window->Preferences->General->Keys, select Build Selected File(s) and under Binding: type your shortcut, for example Shift+F10.
    – Danijel
    Aug 17, 2020 at 13:19
-2

If you're using makefile project. Simply add '-j n' (n specifies the concurrent job number) into your make parameter.

open 'project properties' -> 'C/C++ Build' -> 'Behavior'(page label) -> 'Build (incremental build'(edit box)

e.g. change it to '-j 3 all', will tell make to compile 3 files at same time.

Of course, make will detect file dependencies to decide whether the files can be compiled at same time.

cheers

2
  • 1
    I think eclipse C++ project is using 'make' internally. So you can check the parameters even if it's not a makefile project.
    – Rox
    Dec 10, 2013 at 13:03
  • make -j is for parallel building. Nothing to do with the question...
    – Aubin
    Dec 18, 2019 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.