16

I am working with Eclipse CDT and I want to build the current project only, not any referenced project. Is this somehow possible?

The idea behind this is, that I want to distinguish between "Build Project" and "Build all projects" (in which case, referenced libraries should be built as well).

Thanks in advance, Martin

Martin C.
  • 12,140
  • 7
  • 40
  • 52
  • Not possible atm, but there is an open bug for this: http://stackoverflow.com/questions/2644138/how-to-build-current-project-only-in-eclipse-cdt-on-build-project – Leo Ufimtsev May 21 '15 at 19:56
  • 1
    @LeoUfimtsev your comment links back to this question... – Martin C. May 21 '15 at 22:10

6 Answers6

32

I use another workaround; I changed the default key binding for "Build All" to Alt+Ctrl+B, and changed the binding to "Build Project" to "Ctrl+B".

If you didn't want to mess with the defaults you could add the custom binding (e.g., Alt+Ctrl+B directly to "Build Project".

To change keyboard shortcuts go to &Window, &Preferences, and search for "keys".

Leo
  • 2,775
  • 27
  • 29
9

Shortcut Key Method

Another way is to change the shortcut key for building a project eg. Ctrl-B to only Build Project, instead of Build All.

  1. Go to Window -> Preferences
  2. In General -> Keys, find "Build" in the filter
  3. There are two cases, Build All and Build Project.
  4. Personally, I set Ctrl-B to Build Project by pressing Ctrl-B in the Binding Box
  5. Next I set Ctrl-A Ctrl-B sequence to build all Projects

Try it out

Ethan Lim
  • 159
  • 2
  • 8
8

I'd love to have a better answer for this - the only workaround I know of is to go and actually close all the projects but the one you want built.

JustJeff
  • 12,640
  • 5
  • 49
  • 63
  • Yes, but as you say, it is a "weak" workaround, as in this case code-completion won't work as well. What a pity that this is not possible at the moment. – Martin C. Aug 11 '11 at 09:18
  • 2
    @Martin C. - it's not just weak, it's a complete nuisance. I'd love to be able to have a couple of small utilities as side projects to a rather large application project, but every build of a small util incurs the full rebuild on the large project. Closing and opening projects all the time is just about impractical. – JustJeff Aug 11 '11 at 10:40
  • This does not work in recent eclipse versions. It will throw an error about referenced projects being open. – Leo Ufimtsev May 21 '15 at 19:51
2

You can right click on the project explorer and choose "Build Project", or just use the:

"Project" menu -> "Build Project"
user
  • 86,916
  • 18
  • 197
  • 190
ekr
  • 21
  • 1
0

I found that 'Build Project' is grayed (disabled) in the Project menu (and not in the Project Explorer context menu) when the Project -> 'Build Automatically' option is checked. I unchecked that and can now independently build my projects.

Mike
  • 916
  • 12
  • 14
  • Hi, of course you need to disable "Build Automatically", still if you select "Build Project" (Ctrl-B), it will automatically build all dependencies of the project as well. That's what I want to avoid. – Martin C. Nov 25 '14 at 10:02
0

I un-reference the projects. Somehow the newest CDT is still able to find things in the code.

Build only the project dindn't work as it would still build all.

Leo Ufimtsev
  • 6,240
  • 5
  • 40
  • 48